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

You want to add two arrays together. How would you do that?

476


What are the features of perl language?

584


What does cgi program store?

531


Write syntax to use grep function?

544


What is the closure in PERL?

564






How are parameters passed to subroutines in perl?

495


How do you you check the return code of a command in perl?

572


What happens in dereferencing?

526


List the data types that Perl can handle?

568


Explain ivalue in perl?

522


Why do we use "use strict" in perl?

520


How to read multi lines from a file in perl?

497


Explain regular expression in perl?

522


How to open and read data files with Perl

601


Explain goto expr?

483