Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Out of memory error!!!

by davido (Archbishop)
on Mar 27, 2013 at 18:00 UTC ( #1025775=note: print w/ replies, xml ) Need Help??


in reply to Out of memory error!!!

Change "foreach $line2 ( <INFO> ) {..."

to

"while( my $line2 = <INFO> ) {..."

Your current implementation slurps the flat file into memory because foreach is a ranged-based loop that evaluates <INFO> in list context, which gives you slurp behavior. while() is a conditional based loop, and thus evaluates <INFO> in scalar context, which gives you its iterator behavior.


Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2016-08-25 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (362 votes). Check out past polls.