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

Answer Posted / mahendra ratnakar

Technically, there's no difference between for and foreach
other than some style issues.

One is an alias of another. You can do things like this

foreach (my $i = 0; $i < 3; ++$i)

{ # normally this is foreach print $i, "n";}


for my $i (0 .. 2)

{ # normally this is for print $i, "n";}


- exec runs the given process, switches to its name and
never returns while system forks off the given process,
waits for it to complete and then returns.

Is This Answer Correct ?    12 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the peculiarity of returning values by subroutines in perl?

490


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

500


When does circular reference occur?

525


How can you use Perl warnings and what is the importance to use them?

542


How does polymorphism work in perl?

520






Define perl scripting?

581


Perl regular expressions are greedy" what does this mean?

505


What is the difference between perl list and perl array?

473


What is the use of –w?

533


Write a program that shows the distinction between child and parent process?

516


How will you open a file in a write-only mode in perl?

482


What does the qq{ } operator do?

554


You want to download the contents of a url with perl. How would you do that?

507


How to sort arrays in perl?

631


Why to use perl scripting?

531