in reply to Is there a way to clean up this backticks wrapper?
sub cmd_wrapper { my $cmd = shift; my @out; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm 15; # Give the command 15 seconds to return @out = `$cmd`; alarm 0; }; return wantarray ? @out : join '', @out; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a way to clean up this backticks wrapper?
by Argel (Prior) on Feb 16, 2010 at 00:31 UTC |