fx has asked for the wisdom of the Perl Monks concerning the following question:
Using:
open(FILE, "<some_file.txt"); while(<FILE>) { ## Do some processing... } close(FILE);
I can read a file line-by-line from the top down. How would I go about reading it line-by-line from the bottom up?
Under Linux I suppose it would be fairly easy to have my code read standard input and simply tac (like cat, but in reverse) the file into the script. However, I can't guarantee that tac will be available on all systems where this code will run and would therefore prefer to do it with Perl.
The file in question is large (~600Mb) so I'd rather not read it into memory first :)
Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading a file line-by-line from the bottom up
by davido (Cardinal) on Jan 08, 2004 at 00:28 UTC | |
|
Re: Reading a file line-by-line from the bottom up
by runrig (Abbot) on Jan 08, 2004 at 00:27 UTC | |
|
Re: Reading a file line-by-line from the bottom up
by ysth (Canon) on Jan 08, 2004 at 00:27 UTC | |
|
Re: Reading a file line-by-line from the bottom up
by fx (Pilgrim) on Jan 08, 2004 at 09:39 UTC |