open(my $fh, '|-', "tail", "-n", "+$InStartLineNumber", $InLogFIlePath) or die("Can't tail \"$InLogFIlePath\": $!\n"); while (<$fh>) { ... } close($fh); if ( $? == -1 ) { die "Can't tail \"$InLogFIlePath\": $!\n"); } if ( $? & 0x7F ) { die "Can't tail \"$InLogFIlePath\": Killed by signal ".( $? & 0x7F )."$!\n"); } if ( $? >> 8 ) { die "Can't tail \"$InLogFIlePath\": Exited with error ".( $? >> 8 )."$!\n"); }