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

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

519


How do you find the length of an array?

567


How do I read command-line arguments with Perl?

609


List the data types that Perl can handle?

584


Explain the use of 'my' keyword in perl?

571






What is v-strings?

612


Show the use of sockets for the server and client side of a conversation?

480


what are the strategies followed for multiple form interaction in cgi programs?

514


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

512


Explain about typeglobs?

561


What is the difference between single (') and double (") quote in a string in perl?

490


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

642


Enlist the advantages of using c over perl?

523


Explain chomp, chop, cpan, tk.

548


How the interpreter is used in Perl?

541