use strict; use warnings; use AnyEvent; use AnyEvent::Strict; open(my $fh, '<', 'C:/Temp/TestFile.txt') or die $!; my $done = AnyEvent->condvar; my $watcher = AnyEvent->io ( fh => $fh , poll => 'r' , cb => sub { my $input = <$fh>; print "Input [$input]\n"; if ( $input =~ /^End of processing file/ ) {$done->send; } } ); $done->recv; close $fh or die $!; print "All done!\n";