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
How to determine strings length in perl?
How to compare two strings in perl?
Explain chop?
What is q (single q) operator in perl?
What is the syntax used in Perl grep function?
How the interpreter is used in Perl?
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
How to sort arrays in perl?
What is automatic error handling in perl?
What is perl programming?
What is boolean context?
Explain the execution of a program in perl.
Explain the default scope of variables in perl?
What is perl scripting?
What is the use of '>>' in perl?