June 2005
Beginner
480 pages
10h 31m
English
The simplest way to run a command outside Perl is to use the system function. The system function pauses the Perl program, runs the external command, and then continues running your Perl program. The syntax for system is
system command;
where command is the command that you want run. The return value from system is 0 if everything goes okay or nonzero if a problem occurs. Notice that this result is backward from the normal Perl values of true and false.
The following is an example of system under Unix:
system("ls -lF"); # Print a file listing
# print system's documentation
if ( system("perldoc -f system") ) {
print "Your documentation isn't installed correctly!\n";
}
This next example shows system under MS-DOS/Windows: ...
Read now
Unlock full access