windows program return values vs perl return values from a call to system() -- windows post only





I sent this to a friend to demonstrate the way to manage the return
values from a call to system() out of a perl script. Hopefully I did
it ok. (Post regards windows - activestate perl only.)
------------------------------------------------------------------


use strict; #disable iff too restrictive where iff = 'if and only if'
use warnings; #disable iff too noisy where iff = 'if and only if'


my $prog_to_B_run="C:\\WINNT\\system32\\notepad.exe";
system("$prog_to_B_run");
my $stat=$?;
if ($stat) {
print "The exit code of the program was $stat\n";
}
else {
print "Program ran correctly.\n";
print "In Perl any non-zero number (ex. 1) and non-empty string is\n";
print "counted as true. The number zero,zero by itself in a
string,\n";
print "and the empty string are counted as false.\n";
print "The exit code of the program was $stat.\n";
print "The gotcha is windows signals zero for sucess so,\n";
print "the return value here hits the else and means we are OK.\n";
print "\n";
}


#Again in Perl any non-zero number (ex. 1) and non-empty string is
#counted as true. The number zero,zero by itself in a string, and the
#empty string are counted as false.


.



Relevant Pages