sub executeCommand { my $command = join ' ', @_; ($? >> 8, $_ = qx{$command 2>&1}); } my ($status, $output) = executeCommand ('/bin/ls', '/');