KevinADC 192 Practically a Posting Shark

Lets see your current code.

KevinADC 192 Practically a Posting Shark

OK, but the code you posted is not loading any modules so I thought you were trying to do it all by hand. As far as Windows/Solaris goes the open() command works on both. You can prepend to a file but it is much easier to append to a file. To prepend you can use perls inplace editor or open a new file and add the new data, then open the old file and add the old file data to the new file, then delete the old file and rename the new file to the old file.

KevinADC 192 Practically a Posting Shark

There are a lot of SNMP modules already written that you should probably take a look at:

http://search.cpan.org/search?query=snmp&mode=all

KevinADC 192 Practically a Posting Shark

Yes, I guess. I put the A and B modules in the same directory as the script, not sure if the directory the script is in is found first by @INC or if there is in fact any standard order for @INC at all.

KevinADC 192 Practically a Posting Shark

Good point Bob but it's interesting to note it does work for me as-is. ActiveState Perl 5.8.8 which does include perls 'B' module.

KevinADC 192 Practically a Posting Shark

try changing these lines:

if ($genome_seq =~ $srna_seq){
my $align = lc$1;
$genome_seq =~ s/$1/$align/;
print $genome_seq, "\n";
}

to:

if ($genome_seq =~ /($srna_seq)/){
my $align = lc $1;
$genome_seq =~ s/$1/$align/;
print $genome_seq, "\n";
}

or:

if ($genome_seq =~ s/($srna_seq)/lc $1/e){
 print $genome_seq, "\n";
}

and see if it helps.

KevinADC 192 Practically a Posting Shark

hmmm...not sure what the problem is, your code works fine for me. Are you sure the B.pm file you posted is the file your main script is accessing?

KevinADC 192 Practically a Posting Shark

\014 looks to be octal for a carraige return or newline. so /\014/ is a regexp looking for that pattern in $_. Probably it's counting lines, not sure why it does it like that though. Perl has a variable that tells you how many lines are in a file: '$.'

KevinADC 192 Practically a Posting Shark

Sorry, I'm lost, I don't think I can help you.

KevinADC 192 Practically a Posting Shark

Not sure I understand what your question is. Why doesn't it work with the xml file?

KevinADC 192 Practically a Posting Shark

why are you spamming so many forums with your pointless questions?

KevinADC 192 Practically a Posting Shark

what have you tried so far?

KevinADC 192 Practically a Posting Shark

I see I may have misunderstood your question. If all the radio buttons have the same name and the same value, whats the point anyway? There would be no way to know which one was checked because they all have the same name and the same value. That is just the wrong premise to begin with. That is what your original question asked even though the code does not create the same value $i for each radio button. But maybe you just made a mistake in how you asked the question.

But if the radio buttons had the same name and different values you can get the values but they are all associated with the one name. That is called a multi-value form field: one name but many values.

Or if they have a different name and the same values you can get the radio buttons that were checked because they are no longer a group. Those are just single name single value form fields.

KevinADC 192 Practically a Posting Shark

It should, you must have done something wrong.

KevinADC 192 Practically a Posting Shark

Use the CGI module and it will automatically get multi-valued form fields into your CGI script for you if you call the multi-valued form field in list context, for example:

use CGI qw/:standard/;
print header;
my @first = param('first');#<-- your radio buttons: name='first'
print "$_<br>\n" for @first;

See the CGI module documentation for all the gory details. It s a big module and has lots of functions, takes a while to learn to use well but is a must for CGI coding with perl.

KevinADC 192 Practically a Posting Shark
KevinADC 192 Practically a Posting Shark

I mean use the CGI module. To get you started:

use CGI;
my $query = CGI->new;
my %data = $query->Vars;#gets 'post' or 'get' data in name/value pairs
print $query->header();
foreach my $param (keys %data) {
   print "$param = $data{$param}\n";
}
KevinADC 192 Practically a Posting Shark

should work, but really you should use the CGI module to get post and get (and other) data into your perl based CGI scripts. Trying to do it like you are is not secure, could lead to problems.

KevinADC 192 Practically a Posting Shark

It looks like Activeperl 5.10 comes with Tkx instead of Tk. Activeperl 5.8 comes with Tk and Tkx (I think).

http://aspn.activestate.com/ASPN/docs/ActivePerl/5.10/lib/Tkx.html

So install perl 5.8 if you want to use Tk instead of Tkx.

KevinADC 192 Practically a Posting Shark

You need perl and the Tk modules installed. I would be surprised if they are not included with the distribution of perl you are using.

Open the activestate folder and open the documentation folder (or however it is structured with Active perl 5.10). You should see a list of all the Tk modules that came with your distribution.

Tk is a sort of niche when it comes to coding perl programs, you don't find a lot of perl programmers that are familiar with Tk applications.

I suggest you post on the perl forum at www.tek-tips.com as I know there is one member there that has a lot of Tk experience.

KevinADC 192 Practically a Posting Shark

may as well use "do" instead of eval.

KevinADC 192 Practically a Posting Shark

try using wperl.exe instead of the regular perl.exe

KevinADC 192 Practically a Posting Shark

Get the latest edition of "Perl BookShelf References" (on CD). 5 or 6 books on the CD, including "Learning Perl" and "Advanced Perl Programming" (at least last ime I checked they were included).

You can download (or simply read) a few perl books for free from this site:

http://www.perl.org/books/library.html

They are getting a little old but are still relevant for the most part.

"Data Munging" by Dave Cross is also excellent.

ithelp commented: Thanks. +3
KevinADC 192 Practically a Posting Shark

is this school work? If you are entering integers sort() will not work properly. That is a lexical sort in ASCII order, not numeric order. To properly sort numbers use: <=>

@sorted = sort {$a <=> $b} @unsorted;

KevinADC 192 Practically a Posting Shark

I really don't know, sorry. Find a forum or newsgroup that specializes in bioperl and you may find someone that has experienced this problem and can help.

Good luck.

KevinADC 192 Practically a Posting Shark

You are using math, there are several places in the script that use math operators:

==
<=

maybe more. I do not know if that is where you problems are occuring. Erros/Warnings generally have a line number associated with them that can help pin point where a error/warning is occuring. Run your program and see if a line number and a program/module name gets displayed along with the message.

KevinADC 192 Practically a Posting Shark

I don't know, search CPAN for USB and see if you find anything: http://search.cpan.org/

KevinADC 192 Practically a Posting Shark

If you are using Windows you will want to look into the Win32 class of modules and see if there is one written to communicate with the com port, I suspect there is. Or you can possibly open a pipe to the com port. Where are you stuck? Do you know any perl?

KevinADC 192 Practically a Posting Shark

Well, I had the code pasted into my perl IDE so making some assumptions I adjusted the code. It is of course untested and I am not sure it does what you want, but I guess you can try it:

#!/usr/local/bin/perl
use strict;
use warnings;

open (INPUT, "phastCons_200_chr6.txt") or die "Can't open phastCons: $!\n";
open (INPUT2, "refFlat.txt") or die "Can't open refFlat.txt: $!";
open (OUT, ">>phastCons_noex_chr6.txt") or die "Can't open phastCons_noex: $!\n";
print "phastCons and phastCons_noex and refFlat.txt are all open\n";

OUTTER: while (my $line_ph = <INPUT>) {
    my @fields_ph = split (/\s+/, $line_ph);
    INNER: while (my $line = <INPUT2>) {
        my @fields = split (/\s+/, $line);
        if ($fields_ph[1] eq $fields[2] && $fields_ph[2] < $fields[5] && $fields_ph[3] > $fields[4]) {
            my @ex_start = split (/,/, $fields[9]);
            my @ex_end = split (/,/, $fields[10]);
            for my $i (0 .. $fields[8]-1) {
                if ($fields_ph[2] < $ex_end[$i] && $fields_ph[3] > $ex_start[$i]) {
                    print OUT $line_ph;
                    seek  INPUT2, 0,0; # return to beginning of file INPUT2 - see note below
                    next OUTTER; # go to next line in INPUT
                }
            }
        }
    }
}
close INPUT;
close OUT;
close INPUT2;

Note: this may not work on some systems

KevinADC 192 Practically a Posting Shark

After looking at the code I need some explanations. You are using a binary flag, $overlap, to control some behavior of the script.

You open the first file and read in the first line and $overlap is false (0).

You open the second file and check if $overlap is true (1) and if it is you go to the next iteration (the next line) of the second file.

Now if $overlap is true (1) all the code does is loop through all the lines of the second file without ever doing anything else. If this is a big file that will waste lots of time.

So now the script reads all the lines of the second file and gets back to the second line of the first file. $overlap is once again set to false.

Then it does the same thing again like I described above. It loops through the lines of the second file until $overlap is set to true. Then it loops through all the rest of the lines in the second file again. Then it gets back to the third line of the first file.

That is most likely what is causing the scripts runtime to be so long.

Do you really need to check all the lines of the second file against all the lines of the first file?

How big are the files? Can I see some of the data? Are you reading this thread anymore?

KevinADC 192 Practically a Posting Shark

Your FTP program, or a control panel that the host lets you use are the two most common ways. You can also shell into the account with telnet and set permissions but the host has to allow telnet connections. Using your ftp program is very easy. See it's help files for chmod.

KevinADC 192 Practically a Posting Shark

Can we see some of the data the script is porcessing? Does it just print just one line of data to the output file?

KevinADC 192 Practically a Posting Shark

The code can be written more efficiently. I do not have the time right now to look at it in detail but I will check back later today.

KevinADC 192 Practically a Posting Shark

if you have php questions ask them in the php forum, but I am sure a php script can run a perl program. But if you are at a total loss as to how to even start your project, I really have no idea what to suggest.

KevinADC 192 Practically a Posting Shark

extracting data from a pdf file could be difficult. I have seen many questions posted on forums over the years dealing with pdf files and it seems the perl modules there are for reading pdf files may leave something to be desired. The rest should be relatively easy but probably not for a beginner.

KevinADC 192 Practically a Posting Shark

OK, you may be new, but have you tried anything yet? Please post the code you have written so far so I can see where you need help.

KevinADC 192 Practically a Posting Shark

Image::Magick is sort of a beast all it's own seperate from general perl issues. I recommend you post your concerns on the Image Magick forum:

http://www.imagemagick.org/discourse-server/

Hopefully someone there will be able to help you out. Or wait and see if you get some replies here. I never use it so can't help.

KevinADC 192 Practically a Posting Shark

Hard to say, you have not given enough information. Can you be more specific?

KevinADC 192 Practically a Posting Shark

Personally, I can not understand the specifications of what the program is supposed to do. Posting partial code is not much help, there is no place in the code posted that even prints anything so there is no way to tell why it's not working properly. And you say you have a csv file but you are using tabs in the regexp to pull the data fields out of the lines.

You have to do better at explaining your program specs and please start using code tags around your perl code.

KevinADC 192 Practically a Posting Shark

I will be glad to help, but I don't know where to start. All you have done so far is post a very general and somewhat vague idea of what you want to do. If you can be more specific maybe I can help.

KevinADC 192 Practically a Posting Shark

Do you know any perl at all?

KevinADC 192 Practically a Posting Shark

That modules documentation appears to support upto PPM 3.x, and I also have no idea how to mass add repositories to PPM.

KevinADC 192 Practically a Posting Shark

He has this posted on another forum where it has a number of replies and so far nothing has worked, his input file appears to not be tab delimited. He was told to use \s+ instead of \t , which did not work either.

KevinADC 192 Practically a Posting Shark

ahh, that will be a good thing to remember for future reference.

KevinADC 192 Practically a Posting Shark

just for sanity sake I would add in some error handling for any sytem functions, like these:

if (!(-d "$path/"))
	{
		mkdir("$path/", 0777) or some error handling here;
	}
	if(-f "$path/$filename")
	{
		unlink("$path/$filename") or some error handling here;
	}

make sure everything else is working so you can for sure track it down to the read() function being the real source of the problem, or at least the point where the problem occurs. Why the filehandle is closed is a mystery at this point. It worked, nothing got changed, now it does not work.... thats possible but leads to more fundamental questions, like is the server/computer going bad? Was new software installed or ugraded? It does not sound like a perl problem though.

KevinADC 192 Practically a Posting Shark

Another piece of important information is that while both the program that failed and then worked and this current program are programs to upload files, they are completely different versions of code that work differently. They don't even share any custom libraries in common.

Almost sounds like someone is hitting the "stop" button on the browser while uploading a file. Maybe someone else will have an idea to help you, but I am baffled by the problem you have described.

KevinADC 192 Practically a Posting Shark

Ok :)

KevinADC 192 Practically a Posting Shark

I hope I did not offend you by quoting the manual, but it explains it very well.

KevinADC 192 Practically a Posting Shark

this is a bit of perl magic:

@ARGV = (list of files);
while (<>){

Quoted from perlvar:

# ARGV

The special filehandle that iterates over command-line filenames in @ARGV . Usually written as the null filehandle in the angle operator <> . Note that currently ARGV only has its magical effect within the <> operator; elsewhere it is just a plain filehandle corresponding to the last file opened by <> . In particular, passing \*ARGV as a parameter to a function that expects a filehandle may not cause your function to automatically read the contents of all the files in @ARGV .
# $ARGV

contains the name of the current file when reading from <>.
# @ARGV

The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, not the program's command name itself. See $0 for the command name.
# ARGVOUT

The special filehandle that points to the currently open output file when doing edit-in-place processing with -i. Useful when you have to do a lot of inserting and don't want to keep modifying $_. See perlrun for the -i switch.

/end quote/

http://perldoc.perl.org/perlvar.html

KevinADC 192 Practically a Posting Shark

The "if" condition probably should be written like this:

if(/^pageoncall:) {
         print "pageoncall: $num\@pager.com\n";
      }