my @cmd = ('someprog', 'somearg', 'anotherarg'); my $msg = qx/@cmd 2>&1/; #### if ($?) { # error occures # do whatever }