in reply to system(program) or open(

You can use open() and get the return value from $?. If you check $? after the program closes, that should contain the return value. Well, kinda: from the entry for $? on the perlman:perlvar page:

The status returned by the last pipe close, backtick (``) command, or system() operator. Note that this is the status word returned by the wait() system call (or else is made up to look like it). Thus, the exit value of the subprocess is actually ( $? >> 8), and $? & 127 gives which signal, if any, the process died from, and $? & 128 reports whether there was a core dump. (Mnemonic: similar to sh and ksh.)
Check out perlfunc:open and perlman:perlipc for examples. Since you're writing to the pipe, then you'll probably want to install a handler for SIGPIPE signals, as well. So, your code could be:
$SIG{PIPE} = sub { die "Your pipe handler here! $!"; }; $prog = "/var/qmail/bin/qmail-remote"; $msg = "this is the email message"; open (OUT, "|$prog") or die "Couldn't open Qmail: $!; stopped"; print OUT $msg; close(OUT) or die "Couldn't close Qmail: $! $?; stopped"; my $return_code = $? >> 8; print STDOUT "My return code was $return_code.\n";

stephen