ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
3.2.167 systemsystem This function executes any program on the system for you. It does exactly the
same thing as Because system and backticks block
@args = ("command", "arg1", "arg2"); system(@args) == 0 or die "system @args failed: $?" Here's a more elaborate example of analyzing the return value from system on a UNIX system to check for all possibilities, including for signals and coredumps. $rc = 0xffff & system @args; printf "system(%s) returned %#04x: ", "@args", $rc; if ($rc == 0) { print "ran with normal exit\n"; } elsif ($rc == 0xff00) { print "command failed: $!\n"; } elsif (($rc & 0xff) == 0) { $rc >>= 8; print "ran with non-zero exit status $rc\n"; } else { print "ran with "; if ($rc & 0x80) { $rc &= ~0x80; print "coredump from "; } print "signal $rc\n" } $ok = ($rc == 0); |