Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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


Comment on Re: Out of memory error!!!
Select or Download Code

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 surveying the Monastery: (3)
As of 2014-09-18 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (104 votes), past polls