#!/usr/bin/env perl use strict; use warnings; use autodie qw{:all}; my $command = './pm_test_no_echo_nl.sh'; my $timeout = 3; my $pid = open my $pipe_from, '-|', $command; local $SIG{ALRM} = sub { kill HUP => $pid; die "No data\n" }; alarm $timeout; while (<$pipe_from>) { alarm 0; print; alarm $timeout; }