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.
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How can I grab the last 2 lines of a file?
by AppleFritter (Vicar) on Jul 26, 2014 at 22:05 UTC | |
Re: How can I grab the last 2 lines of a file?
by fishmonger (Chaplain) on Jul 26, 2014 at 23:09 UTC | |
by muba (Priest) on Jul 26, 2014 at 23:19 UTC | |
by Anonymous Monk on Sep 20, 2014 at 12:28 UTC | |
by LanX (Saint) on Sep 20, 2014 at 13:53 UTC | |
Re: How can I grab the last 2 lines of a file?
by LanX (Saint) on Jul 26, 2014 at 22:04 UTC | |
by 1s44c (Scribe) on Jul 27, 2014 at 09:47 UTC |
Back to
Seekers of Perl Wisdom