Upload
kizzy
View
18
Download
0
Embed Size (px)
DESCRIPTION
Process Management. As a scripting language Perl provides the ability to run programs inside a Perl script. For example I could run a “dir” command inside of Perl, munge the output, and print my own version of it You do this using system() exec(). system(). - PowerPoint PPT Presentation
Citation preview
Process Management
• As a scripting language Perl provides the ability to run programs inside a Perl script.– For example I could run a “dir” command
inside of Perl, munge the output, and print my own version of it
• You do this using– system()– exec()
system()
• Argument specifies the program to runsystem( “date” );
• Runs the command and returns the exit status of the programsystem( “data” ) && die “bad command”;
• Standard input, standard output, and standard error are inherited
Fancy Stuff
• This all workssystem( “date > date.out” );
$fileName = “date.out”;
system( “date > $fileName” );
system ( “dir process.perl” );
system ( “dir”, “process.perl” );
Processes and File Handles
• Processes can be started from within file handles– open( DIRPROC, “dir|” );
• All the standard file stuff now applies to the output– @listing=<DIRPROC>;– open( LPR, “|lpr”);– print LPR @listing;
Your Turn!!
• Write a Perl script that prints out the names of the directories and then the names of a the files in the current directory.