go ahead... be a heretic | |
PerlMonks |
Re: how to populate array with last 20 lines of fileby dasgar (Priest) |
on Aug 08, 2017 at 18:56 UTC ( [id://1197028]=note: print w/replies, xml ) | Need Help?? |
I don't know if this is the "best" way, but one route would be to use Tie::File. It basically "represents a regular text file as a Perl array". And since it does not store the entire file into memory, you can use this for large files without major concern about memory usage - although the 8KB size you mentioned in another post isn't too big to store in memory. If you use Tie::File, grabbing the last 20 lines is simply grabbing the last 20 elements of the array.
In Section
Seekers of Perl Wisdom
|
|