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

How do you turn on the perl warnings?

506


How to add elements in a hash in perl?

519


Explain the use of 'my' keyword in perl?

571


What are some common methods to all handles in perl?

514


Explain the default scope of variables in perl?

529






What are scalars?

559


Which functions in perl allows you to include a module file. State their differences.

541


Write a program to decode the data in the form using cgi programming

554


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

469


What are the advantages and disadvantages of perl language?

494


Create a function that is only available inside the scope where it is defined ?

558


How to close a directory in perl?

504


How can you replace the characters from a string and save the number of replacements?

519


What does -> symbol indicates in Perl?

578


What is hash?

566