What is the difference between for & foreach, exec &
system?

Answer Posted / ramesh

Both Perl's exec() function and system() function execute a
system shell command. The big difference is that system()
creates a fork process and waits to see if the command
succeeds or fails - returning a value. exec() does not
return anything, it simply executes the command. Neither of
these commands should be used to capture the output of a
system call. If your goal is to capture output, you should
use the

$result = system(PROGRAM);
exec(PROGRAM);

Is This Answer Correct ?    12 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why aren't Perl's patterns regular expressions?

785


What is the use of command “use strict”?

727


How many types of operators are used in the Perl?

764


What does last statement do in perl?

749


What happens in dereferencing?

716


What is the importance of perl warnings? How do you turn them on?

750


How can the user execute a long command repeatedly without typing it again and again?

677


How do you set environment variables in perl?

736


How to close a directory in perl?

680


What does next statement do in perl?

758


Explain goto label?

704


Which of these is a difference between Perl and C++ ?

748


In CPAN module, name an instance you use.

723


What happens when you return a reference to a private variable?

752


How many data types are there in perl?

732