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 arguements we normally use for perl interpreter?
List the prefix dereferencer in Perl.
Explain subroutine?
How to concatenate strings with perl?
Create a function that is only available inside the scope where it is defined ?
What is the difference between single (') and double (") quote in a string in perl?
Explain split function in perl?
How can we create perl programs in unix, windows nt, macintosh and os/2 ?
Explain the various characteristics of perl.
Give an example of using the -n and -p option.
How do I read command-line arguments with Perl?
What are some common methods to all handles in perl?
how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
How to prevent file truncation in perl?
Which operator in perl is used for the concatenation of two strings?