in reply to system() and output
The easiest way would be to use IPC::Open2. This returns the pid of the process. Once you have the pid, you can use waitpid to retrieve the status. It is returned in perlvar:$?. You need to shift this >> 8 in order to extract the status value.
P:\test>type test.pl #! perl -slw print 'Hello world'; exit 12; P:\test>perl -de1 Loading DB routines from perl5db.pl version 1.19 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> use IPC::Open2 DB<2> $pid = open2( IN, OUT, 'perl58.exe test.pl') or warn $!; DB<3> print <IN>; Hello world DB<4> waitpid $pid, 0 DB<5> print $? >> 8; DB<6> 12
|
|---|