http://www.perlmonks.org?node_id=618200


in reply to Re^2: Don't re-read file for each new pattern...
in thread Don't re-read file for each new pattern...

It's pretty common to see scripts process files one line at a time. So you have code like this:
open FILE, $filename or die "cant open: $!"; while(<FILE>) { chomp; print "read line: $_ \n"; } close FILE;
This loop will iterate once for each line of the file. The instruction "Don't re-read the file..." means don't put a loop like this inside the infinite while(1) loop. Instead, you read all the lines (once) and save them in the @strings array. This is more efficient, because memory access is faster than file I/O.