Perl: the Markov chain saw | |
PerlMonks |
How can I grab the last 2 lines of a file?by Anonymous Monk |
on Jul 26, 2014 at 21:54 UTC ( [id://1095182]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks! I am looking for an efficient way to grab the last 2 lines of a big text file... Ideally, I would like to store the second-to-last line to a variable called $id and the last line to a variable called $name. Of course I can read the file line-by-line but I was wondering if there is a faster way to do it, perhaps without the need of reading the whole file first.
Back to
Seekers of Perl Wisdom
|
|