Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Explain the execution of a program in perl.

921


What is the use of –w?

869


Why should I use the -w argument with my Perl programs?

914


What is the purpose of goto expr statement?

835


What are prefix dereferencer?

850


Explain perl. When do you use perl for programming?

834


What does perl do in linux?

885


what is the function of Return Value?

996


What are the various advantages and disadvantages of perl?

841


How to code in perl to implement the tail function in unix?

882


what are the two ways to get private values inside a subroutine or block?

875


How do I pass a command line argument in perl?

919


How does polymorphism work in perl? Give an example.

809


Can we load binary extension dynamically?

887


How interpreter is used in perl?

882