In perl , when will you use system and exec command?
-
(system cmd)When I don’t want to explicitly capture the output and return the control to perl script. (exec cmd) When I want to capture the output and don want to return back to the perl script
-
(exec cmd)When I don’t want to explicitly capture the output and return the control to perl script. (system cmd) When I want to capture the output and don want to return back to the perl script
-
(system cmd)When I want to execute system commands only (exec cmd) When I want to execute non system commands only
-
(exec cmd)When I want to execute system commands only (system cmd) When I want to execute non system commands only
The system() function executes an external command and returns control to the Perl script after completion, allowing continuation. The exec() function replaces the current Perl process with the external command - the script terminates and doesn't return. Use system() when you want to continue script execution after the command; use exec() when the external command is the final step.