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

What is the use of command “use strict”?

567


Why to use perl?

543


Which feature of perl provides code reusability?

571


What does a die() function do in perl?

544


How many data types are there in perl?

536






What are the different string manipulation operators in perl?

535


Explain regular expression in perl?

532


Why aren't Perl's patterns regular expressions?

595


How can you call a subroutine and identify a subroutine?

506


How to get help for perl?

591


Perl regular expressions are greedy" what does this mean?

505


Explain '->' in perl?

505


How to replace perl array elements?

532


How to determine strings length in perl?

539


What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

546