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 |
What is the use of strict?
How to convert strings into an array in perl?
How can we create perl programs in unix, windows nt, macintosh and os/2 ?
Explain perl. When do you use perl for programming?
How can you create an object of a class in a package?
How interpreter is used in perl?
How to read a directory in perl?
What does perl do in linux?
What is the importance of perl warnings?
what is the function of Return Value?
What are some of the key features of objects in perl?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?