There are two ways to call a shell command from the Perl script.
We use the backticks (``
) syntax when we want to capture the output of the shell command. We provide the command between the backticks.
If we don't want to capture the output of the shell command, we use the system
function, as shown below. The system
function will just display the output.
# usage backticksmy $output = `ls -l`;print "------display the captured output with backticks------ \n";print $output;print "\n------display the output of disk usage command with system------- \n";#usage of systemsystem("df -h");
output
.system
function. The system
function displays the output.