November 2013
Beginner
900 pages
56h 6m
English
Perl can perform for you any process you might ordinarily perform by typing commands to the shell through the \\ syntax. For example, the code in Listing 40.4 prints a directory listing.
LISTING 40.4 Using Backticks to Access the Shell
$curr_dir = 'pwd';@listing = 'ls -al';print "Listing for $curr_dir\n";foreach $file (@listing) { print "$file";}
Note
The \\ notation uses the backtick found above the Tab key (on most keyboards), not the single quotation mark.
You can also use the Shell module to access the shell. Shell is one of the standard modules that comes with Perl; it allows creation and use of a shell-like command line. Look at the following code for an example:
Read now
Unlock full access