On Tue, Sep 25, 2001 at 12:59:51PM -0400, Uri Guttman wrote:
> >>>>> "MGS" == Michael G Schwern <[EMAIL PROTECTED]> writes:
>
> MGS> Backwards?
>
> MGS> File.read_backwards($filename) {
> MGS> print
> MGS> }
>
> not trivial but not too hard. check out File::ReadBackwards for a way to
> do it efficiently in perl5. it requires some careful seeking, buffering
> and scanning for the line endings. it probably should be a module and
> not core. it could be combined with a bunch of other useful file or file
> iterators classes.
The details of the implementation are irrelevent (in fact, the guts
will probably be nearly the same as File::ReadBackwards). The point
is, instead of the interface being this:
use File::ReadBackwards;
$bw = File::ReadBackwards->new( 'log_file' ) or
die "can't read 'log_file' $!" ;
while( defined( $log_line = $bw->readline ) ) {
print $log_line ;
}
or this:
use File::ReadBackwards;
tie *BW, File::ReadBackwards, 'log_file' or
die "can't read 'log_file' $!" ;
while( <BW> ) {
print ;
}
it can be this:
File.read_backwards('log_file') {
print;
}
Ta da!
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
<Skrewtape> I've heard that semen tastes different depending on diet. Is that
true?
<Skrewtape> Hello?
<Schwern> Skrewtape: Hang on, I'm conducting research.