in reply to getting output from backticks
a sample invocation:function sysub { my $cmd = shift; my $rc = 0xffff & system $cmd; if ($rc == 0xffff) { print "command failed: $!\n"; } elsif ($rc > 0x80) { $rc >>= 8; print "ran with nonzero exit status $rc\n"; } elsif ($rc != 0) { print "ran with "; if ($rc & 0x80) { $rc &= ~0x80; print "coredump from "; } print "signal $rc\n"; } return ($rc != 0); }
&sysub ("cp $source $target");Unfortunately, I never researched the reasoning behind all the bit-twiddling but it has served me well for several years. I would appreciate enlightenment from more advanced monks on this aspect of the code. Also, any suggestions or improvements would be welcomed.
|
|---|