/usr/share/doc/libio-async-perl/examples/tail-logfile.pl is in libio-async-perl 0.71-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #!/usr/bin/perl
use strict;
use warnings;
use IO::Async::Loop;
use IO::Async::FileStream;
my $FILE = shift @ARGV or die "Need FILE";
my $loop = IO::Async::Loop->new;
open my $fh, "<", $FILE or die "Cannot open $FILE for reading - $!";
my $filestream = IO::Async::FileStream->new(
read_handle => $fh,
on_initial => sub {
my ( $self ) = @_;
$self->seek_to_last( "\n" );
},
on_read => sub {
my ( undef, $buffref ) = @_;
while( $$buffref =~ s/^(.*)\n// ) {
print "$FILE: $1\n";
}
return 0;
},
);
$loop->add( $filestream );
$loop->run;
|