Don't ask to ask, just ask | |
PerlMonks |
Re: Loading a part of the file to array using Tie::Fileby roboticus (Chancellor) |
on Nov 21, 2017 at 15:15 UTC ( [id://1203893]=note: print w/replies, xml ) | Need Help?? |
The problem with memory is that you're reading all the lines of the file at once. Rather than doing that, read the file line by line and do your processing. That way you can handle a file of any size. You can do so like this:
As you'll notice, I intentionally changed the way you did things: There's no real need to spawn two additional processes to perform tasks that perl can already do for you. Especially not to:
The three-argument form of open is safer than the old two-argument open. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|