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; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

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
    Duh!! I was wracking my brain for fancy tricks, not something simple like join! I knew I was too close to the problem. Thanks!!

    Elda Taluta; Sarks Sark; Ark Arks