my $err = `(cp xyz.dat abc.dat && cp xyz.dat2 abc.dat2) 2>&1`; if ($?) { print "Error message: $err"; print "Exit status: ", $? >> 8; }