in reply to How can we read each line from a file onto an array?
above loads the whole file at once in memory.my @lines = <FILE>
Instead, you can do something like
This code will still traverse the whole file, so wont be faster but it will load only one line at a time in the memory - helpful if you want to parse 4GB file and have only 2 GB RAM ;)while(my $line=<FILE>){ do_something; }
|
|---|