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 / 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 |
Explain lists ?
What are some common methods to all handles in perl?
what r the different type of function in perl ???
What does the qq{ } operator do?
How and what are closures implemented in perl?
What is the use of '>>' in perl?
Explain the various characteristics of perl.
Write a program to decode the data in the form using cgi programming
Explain returning values from subroutines?
What is the Common Gateway Interface?
What is eval function in perl?
Define dynamic scoping.