#!/usr/bin/perl use warnings; use strict; use constant TRUE => 1; use constant FALSE => 0; use Linux::Inotify2; use IO::Handle; open my $fh, '<', $ARGV[0] or die "Cannot open file: $!\n"; $fh->blocking( FALSE ); my $inotify = new Linux::Inotify2 or die "Unable to creat Linux::Inotify2 object: $!\n"; $inotify->watch( $ARGV[0], IN_MODIFY, \&file_changed ) or die "watch creation failed"; sub file_changed { while ( sysread $fh, my $buff, 50 ) { syswrite STDOUT, $buff; } } print <$fh>; 1 while $inotify->read; close $fh;