Shlomi Fish wrote:

On 2 Mar 2012 02:48:28 -0000
Peter Scott<pe...@psdt.com>  wrote:

It doesn't have flaws.  You could do it without the module with a piped
open:

sub run_cmd
{
   my $cmd = shift;

   open my $fh, '-|', "$cmd 2>&1" or die "open: $!";
   print while<$fh>;
   close $fh;
   return $?>>  8;
}

Interesting. I did not realise that open '-|' with a single argument will pass
this as a small shell program. But it does:

It _has_ to use the shell because of the "2>&1" redirection of stderr won't work without the shell doing the redirection.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to