in reply to tail -1 emulation efficiency

How about this:

use Tie::File; use strict; my @ry=(); tie @ry,"Tie::File","myfile" or die "$!"; my $line=$ry[$#ry]; untie @ry; print $line;

Replies are listed 'Best First'.
Re: Re: tail -1 emulation efficiency
by woodstea (Sexton) on May 06, 2004 at 03:11 UTC
    I'm afraid neither of the tie examples, this one or the one above, compare very well in terms of performance with the seek solution:
    Using tail module w/ tie: 0.200u 0.050s 0:00.32
    First example w/ tie: 0.270u 0.030s 0:00.38
    My example using seek: 0.030u 0.010s 0:00.07
    
    I'm happy to have the examples though, just learned about tie tonight -- thanks.