in reply to tail -f foo.bar | cat -n

Hi,
File::Tail can do it for you...
my $count = 0; my $line; # from their POD use File::Tail; # "tail => -1" will start from the beginning of the file my $file=File::Tail->new(name => "/some/log/file", tail => -1); while (defined($line=$file->read)) { print ++$count, " ", $line; }

Regards,
svenXY

update: added the actual line output to mimic cat -n correctly
update 2: works for me
update 3: added tail => -1 (see comment)

Replies are listed 'Best First'.
Re^2: tail -f foo.bar | cat -n
by ProfessorHaroldHill (Initiate) on Feb 26, 2008 at 10:30 UTC
    Looks good on my test suite too, thank you Kev
    The sadder but wiser Perl for me ...