I want to execute an external command from within my Perl script, putting the output of both stdout and stderr into a $variable of my choice, and to get the com
$variable
Actually, the proper way to write this is:
#!/usr/bin/perl $cmd = 'lsss'; my $out=qx($cmd 2>&1); my $r_c=$?; print "output was $out\n"; print "return code = ", $r_c, "\n";
You will get a '0' if no error and '-1' if error.