Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Automated form submission

by Anonymous Monk
on Mar 05, 2002 at 03:17 UTC ( [id://149274]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://149274]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-10-09 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (45 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.