5 with help from perlfaq5
7 Displays the whole file with leading line number and timestamp and
8 switches to 'tail -f' mode when the end is reached.
12 use Time
::HiRes
qw(time sleep);
16 my $file = shift or die "Usage";
17 open GWFILE
, $file or die "Could not open '$file': $!";
23 open GWFILE
, $file or die "Could not open '$file': $!";
25 for ($curpos = tell(GWFILE
); $line = <GWFILE
>; $curpos = tell(GWFILE
)) {
26 if (++$i > $lines - 10) {
28 my $localtime = sprintf "%02d:%02d:%02d", @time[2,1,0];
30 $fractime =~ s/\d+\.//;
32 printf "%5d %s.%s %s", $i, $localtime, substr($fractime,0,4), $line;
36 seek(GWFILE
, $curpos, 0); # seek to where we had been