in reply to Re: Automated form submission
in thread Automated form submission

Thanks guys for the response...it seems so obvious now...can't believe I couldn't figure it out
No worries Scott, I plan to use this program as a model for many other things besides NCBI.
I am now having another problem that I had working before...I am trying to loop in many individual pieces of text...one at a time, after receiving the response from the server. Here is the code that worked before in a simple manner...
#!/usr/bin/perl use lib "/System/Library/Perl"; use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new(); print "Which file do you wish to process?\n"; chomp($file=<STDIN>); open (FILE, "$file") || die "$!"; print "Please enter name for the output file\n"; chomp($out=<STDIN>); open (OUT, ">$out") || die "$!"; while (<FILE>) { @acc = <FILE>; } print "\nPROCESSING file $file...\n"; for ($i=0;$i<=$#acc;$i++) { $accession = $acc[$i]; chomp $accession; etc....I have made the necessary corrections now

I continue to get an error from the server and I only have one sequence in the input file.
Any thoughts??
Thanks again guys!
Dr.J

Replies are listed 'Best First'.
Re: Re: Re: Automated form submission
by scain (Curate) on Mar 05, 2002 at 14:45 UTC
    Well, I am not sure of the exact nature of your problem from you description, but I would clean up a few stylistic things, and maybe along the way your problem will clear up too.

    First, when reading in a file you can either do it in a while loop, in which case it will read in line by line, or you can slurp it all at once by assigning the filehandle to an array (each line becoming an element of the array). You've done a hybrid of both here, and that may be the source of your problem. Most people agree that the way to go is to read line by line, that way if you get an input file that is bigger than you expect, you don't pay any penalties for slurping a huge file into memory.

    Also, since you are reading the file in line by line, you can do the rest of the work in the while loop, resulting in:

    print "\nPROCESSING file $file...\n"; while (<FILE>) { chomp $_; $accession = $_; etc....I have made the necessary corrections now }
    If you desided you don't want to do it that way, I would at least change your for loop to a more Perlish loop:
    foreach my $accession(@acc) { chomp $accession; etc....I have made the necessary corrections now }
    Good luck,
    Scott
      Thanks for your help Scott...I will try this
      I suppose it is clear that I am somewhat of an amateur, and so I appreciate it.
      You might see me sometime in the future asking another simple question,
      Cheers,
      Dr.J