Simple... and neat using File::Temp:
use File::Temp; sub cmdrun { my $cmd = shift; my $out = File::Temp->new(); my $err = File::Temp->new(); local $/; `$cmd >$out 2>$err`; $?>>8, scalar <$out>, scalar <$err> } use Data::Dumper; print Dumper cmdrun( q(perl -le "warn q(NOISE); print q(OUTPUT); exit +42;") );
In reply to Re^2: thread save calling an external command
by Anonymous Monk
in thread thread save calling an external command
by Paul.Unix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |