use warnings; use strict; use IPC::Run qw( run timeout ); my @command = ('ls', '-la'); #print "cmd = @command\n"; my ( $buff ); my $exit = '0'; run \@command, \$buff, timeout(10) or $exit = 1; print "exit code = $exit\n";