Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: How can I grab the last 2 lines of a file?by LanX (Saint) |
on Jul 26, 2014 at 22:04 UTC ( [id://1095183]=note: print w/replies, xml ) | Need Help?? |
You need to seek on a file handle to jump to the end. Since its byte and not line based you'll need to read a sufficiently big trailing chunk into a line array and take the last two entries. (and if the chunk wasn't big enough try a bigger one ) Search the archives, similar questions have been asked before and adjust the code to your needs. > Ideally, I would like to store the second-to-last line to ... Ideally someone would bring me now a banana split and a hot espresso to my sofa...
Cheers Rolf (addicted to the Perl Programming Language and ☆☆☆☆ :)
update... or a strudel with vanilla ice cream... Hmm! :)
updateNo espresso yet? Hence no tip! :( But at least a link http://www.google.com/search?q=read+last+n+lines+of+a+file+perl+site:www.perlmonks.org
In Section
Seekers of Perl Wisdom
|
|