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
Explain the execution of a program in perl.
What is the use of –w?
Why should I use the -w argument with my Perl programs?
What is the purpose of goto expr statement?
What are prefix dereferencer?
Explain perl. When do you use perl for programming?
What does perl do in linux?
what is the function of Return Value?
What are the various advantages and disadvantages of perl?
How to code in perl to implement the tail function in unix?
what are the two ways to get private values inside a subroutine or block?
How do I pass a command line argument in perl?
How does polymorphism work in perl? Give an example.
Can we load binary extension dynamically?
How interpreter is used in perl?