[Chapter 7] 7.2.56 Shell - Run Shell Commands Transparently Within Perl
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T02:03:56Z

#

| Chapter 7 The Standard Perl Library |

### 7.2.56 Shell - Run Shell Commands Transparently Within Perl

    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.

7.2.55 SelfLoader - Load Functions Only on Demand |  | 7.2.57 sigtrap - Enable Stack Backtrace on Unexpected Signals