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
What are the advantages of perl programming?
How do I read command-line arguments with Perl?
What are the arguements we normally use for perl interpreter?
What is a chomp() function in perl?
What is stdin in perl?
Explain the default scope of variables in perl?
What are the advantages of c over Perl?
Explain the difference between declarations of 'my' and 'local' variable scope in perl?
What is “grep” function in perl?
what are the two ways to get private values inside a subroutine or block?
What are the different types of perl operators?
Explain the functioning of conditional structures in perl.
What are scalars in perl?
How do you find the length of an array?
How to read a directory in perl?