How to Call a Shell From a Perl Script
- 1). Open a blank file in any text editor.
- 2). Type the line
#! /usr/bin/perl
to start the Perl script. - 3). Type the line
system("ls", "-l", "-a");
to execute the command "ls -la" in the system shell. - 4). Type the line
print "The directory was listed! \n";
to print the line "The directory was listed!" to the screen. - 5). Save the file as "list_dir.pl".
- 6). Type the command "perl list_dir.pl" at a command prompt to execute the script. The contents of the directory in which the script is running will be printed to the screen.