Not like system(), backticks involves a shell processing, if you do not want this happen in your script, here is one way.

Usually you use this way to call backticks

    $ret = `system cmd`;

Use this to avoid shell processing, do this:

    exec 'system cmd';

The exec function executes a system command and never returns; use system() instead of exec if you want it to return.

It fails and returns false only if the command does not exist and it is executed directly instead of via your system's command shell.

It's a function of perl, it's like return statement in perl function.

$output = exec 'sleep 10; date'  ;
print $output;

run this script, and you will get

1453252604.26704sleeped 100 msecs
Tue Jan 19 17:16:44 PST 2016

You can tell that use exec, the script won't sleep 100 secs. And you won't get return from exec.



Comments powered by CComment