use IPC::Run qw( run ); my($out, $err); my @top = qw( top -b -n1 ); run \@top, \undef, \$out, \$err or die "top returned $?";