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

What is the importance of perl warnings?

1225


You want to connect to sql server through perl. How would you do that?

987


When would `local $_' in a function ruin your day?

999


What does 'do' statement do in perl?

1051


How to read a file into a hash array?

1090


Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.

933


What is Perl?

1053


What is perl? What is the basic command to print a string in perl?

915


What syntax is used for grep() function?

1261


What is the use of -t?

1022


Create a function that is only available inside the scope where it is defined ?

1052


Explain the difference between "my" and "local" variable scope declarations. ?

1135


Can inheritance be used in perl?

1039


Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.

1070


How to determine strings length in perl?

1016