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

Answer Posted / mukesh

for and foreach are alias of each other.But syntax is different.

e.g for(my $i = 0; $i < 3; ++$i){print $i}
e.g foreach my $i (0 .. 2){print $i}

i.e in foreach we can take always only array of elements or
range of elements.But in for we dont have to take the array
or range always.here we can provide condition of the loop
where it is not true for foreach.

Is This Answer Correct ?    28 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of operators are used in the Perl?

574


what are the three groups involved in information sharing?

467


What is the difference between use and require in perl?

463


Explain the meaning of perl one-liner?

503


Explain regular expression in perl?

520






Why do you use Perl?

536


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

470


Explain gmtime() function in perl?

559


How to dereference a reference?

556


Why we use CGI?

2105


What are the steps involved when the cgi program starts running?

500


What rules must be followed by modules in perl.

553


In Perl, what is grep function used for?

517


Define say() function in perl?

531


Explain the difference between "my" and "local" variable scope declarations. ?

555