## 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: $?" # Can do I/O to sub refs and filenames, too: run \@cmd, "in.txt", \&out, \&err or die "cat: $?" run \@cat, "in.txt", '>>', "out.txt", '2>>', "err.txt" ; # Redirecting using psuedo-terminals instad of pipes. run \@cat, 'pty>', \$out_and_err ;