Changes

Execute System Command and Shell from Perl

837 bytes added, 12:34, 14 April 2008
The following lines were added (+) and removed (-):
Passes a string along to the underlying system.Passes a string along to the underlying system.  In short, exec will abandon the current program to run another.The exec function executes a system command without return.The exec function executes a system command without return. The exec() function executes the command specified and never returns to the calling program, except in the case of failure because the specified command does not exist AND the exec argument is an array. Like in system(), is recommended to pass the arguments of the functions as an array.  exec ('foo')  or print STDERR "couldn't exec foo: $!"; { exec ('foo') }; print STDERR "couldn't exec foo: $!";  The "backtick" is the ` character (ASCII code 96, backwards-slanted single quote, or a grave accent without the character).  By quoting a command string with backticks the command is processed by the system and whatever is on stdout ends up where the quoted expression is within the Perl program.The "backtick" is the ` character ([[ASCII]] code 96, backwards-slanted single quote, or a grave accent without the character).  By quoting a command string with backticks the command is processed by the system and whatever is on stdout ends up where the quoted expression is within the Perl program. print `mplayer hellobaby.wav &> /dev/null`; $directoryListing = `ls -laF /home/al`; print $directoryListing;You can use Perl variables inside of the backtick operators.  $home = '/home/savannah'; $directoryListing = `ls -laF $home`; print $directoryListing; perl -e 'my $audio = "bell.wav"; print `mplayer /usr/share/sounds/$audio &> /dev/null`;'
Bureaucrat, administrator
16,192
edits