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...

while(my($key, $value) = each(%hash) ) { print "$key =>
$value\n"; }

my($key, $value); while(($key, $value) = each(%hash) ) {
print "$key => $value\n"; }


What is the different between these two code in case of "my"
usage ?

Answer Posted / sourisengupta

case 1:

by decalring "my" we are making the variable local.
So you cant access the value of those variable from the
outsite of that block.

case 2:

here you can access the value of the code from the
outside of that code.

"my" is generally used to protect the variable from
mingling.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I display all array element in which each element will display on next line in perl ?

878


What does this symbol mean '->'?

927


What is the difference between perl list and perl array?

825


What is the use of strict?

873


Why is it hard to call this function: sub y { "because" } ?

886


How to get help for perl?

942


Differentiate between use and require, my and local, for and foreach and exec and system

853


How do I replace every TAB character in a file with a comma?

929


What are arrays in perl?

926


How does polymorphism work in perl?

870


How can you call a subroutine and identify a subroutine?

954


Why to use perl?

895


What rules must be followed by modules in perl.

953


what are the three groups involved in information sharing?

840


How do I print the entire contents of an array with Perl?

913