If you can use ssh instead of rsh (which maybe you should be
doing anyway :), you can use Net::SSH::Perl, which
has a method to execute a command remotely and get back
the stdout, stderr, and exit status.
my $ssh = Net::SSH::Perl->new($host);
my($out, $err, $exit) = $ssh->cmd($cmd);