## First,a command to run: my @cat = qw( cat ); ## Using run() instead of system(): use IPC::Run qw( run timeout ); run \@cmd, \$in, \$out, \$err, timeout( 10 ) or die "cat: $?"