Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: String related question

by Anonyrnous Monk (Hermit)
on Feb 02, 2011 at 12:53 UTC ( #885733=note: print w/ replies, xml ) Need Help??


in reply to Re^2: String related question
in thread String related question

For tasks like you've described, there's no reason to read the entire file into an array. It's usually better to process the file line by line, because it scales in case your files should get huge. I.e. for, say, a 1 GB file, you'd need several gigs of RAM to hold the contents in the array, while if you process line by line, you'll only ever need storage for one line.

open my $fh_in, "<", $proteinfilename or die "Couldn't open '$protein +filename': $!"; open my $fh_out, ">", $outfilename or die "Couldn't open '$outfilename +': $!"; while (my $line = <$fh_in>) { if ($line =~ /^AD/) { print $fh_out " $line"; } }


Comment on Re^3: String related question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-12-26 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls