Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: out of memory error while reading file contents into an array

by tokpela (Chaplain)
on Aug 11, 2009 at 14:03 UTC ( #787634=note: print w/ replies, xml ) Need Help??


in reply to out of memory error while reading file contents into an array

You should iterate over the filehandle directly.

use strict; use warnings; my $filename = 'filename.txt'; open(my $fh, $filename) or die "cann't open file filename : $!\n"; while (<$fh>) { my $line = $_; next if ($line =~ /^\s*$/); # skip blank lines chomp($line); # remove line endings # .... do your coding here on each line } close($fh);


Comment on Re: out of memory error while reading file contents into an array
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (15)
As of 2014-07-28 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (207 votes), past polls