use strict; use warnings; my $pid = open(my $fileHandler, '-|', "./test.exe" ); my $start = time; my $timeout = 2; while (<$fileHandler>) { print "$_\r"; # \r to not overrun output screen buffer last if ((time - $start) >= $timeout); } print "\nTimeout! - Time to kill pid: $pid\n"