in reply to Reading Lines from Text file
perl -e "@l = <>; print 'first : ', $l[0], 'last : ', $l[$#l];" filen +ame
perl -e "$first = <>; while($line = <>) { $last = $line; }; print 'fir +st : ', $first, 'last : ', $last;" filename
It's still not recommended for larges files because the entire file is being read. If you have a 4gbyte file and your I/O subsystem is only able to read 10 Mbytes/second you're going to take 400 seconds to get the answer.
Update: Use File::ReadBackwards . I didn't knew about this module and ended up reinventing the wheel (and ended up with a square wheel when compared with File::ReadBackwards :-)
There's More Than Way To Do It,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Reading Lines from Text file
by holli (Abbot) on Feb 02, 2006 at 19:48 UTC |