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
Is perl compiler or interpreter?
How we can navigate the xml documents?
What can be done for efficient parameter passing in perl? Explain.
What are the steps involved in configuring a server using cgi programming?
Write syntax to use grep function?
What is perl? What is the basic command to print a string in perl?
Difference between the variables in which chomp function work ?
You want to connect to sql server through perl. How would you do that?
Explain the functioning of conditional structures in perl.
Why do you use Perl?
Explain socket programming in perl?
How can you replace the characters from a string and save the number of replacements?
What does the qq{ } operator do?
How to implement a stack in Perl?
What happens in dereferencing?