use Shell qw(date cp ps); # list shell commands you want to use $date = date(); # put the output of the date(1) command into $date cp("-p" "/etc/passwd", "/tmp/passwd"); # copy password file to a tmp file print ps("-ww"); # print the results of a "ps -ww" command
This module allows you to invoke UNIX utilities accessible from the shell command line as if they were Perl subroutines. Arguments (including switches) are passed to the utilities as strings.
The Shell module essentially duplicates the built-in backtick functionality of Perl. The module was written so that its implementation could serve as a demonstration of autoloading. It also shows how function calls can be mapped to subprocesses.