use IPC::Open3; use POSIX ":sys_wait_h"; package SysCall3; sub exec{ my $self = shift; my $command = shift; $self = {}; my $pid = open3 my $wh, my $rh, my $eh, $command; $self -> { EXITCODE } = $?; close $wh; $self -> { STDOUT } = <$rh>; close $rh; $self -> { STDERR } = <$eh>; close $eh; waitpid $pid,0; return bless $self; } sub getinfo( my $self = shift; return $self -> { shift() }; } 1; #### use SysCall3; my $nasty = SysCall3 -> exec( 'bigNastyProgram' ); for my $err ( $nasty -> getinfo( 'STDERR' ) ) { # process the error output print STDERR $err; } for my $out ( $nasty -> getinfo ('STDOUT' ) ) { # process the stdout print $out; } my $code = $nasty -> getinfo( 'EXITCODE' ); # process return code exit $code; # if wanting to pass control back to the o/s