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 |
Write syntax to use grep function?
Define operators used in perl?
What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?
How many ways can we express string in Perl?
How to close a file in perl?
Is perl a case sensitive language?
Can inheritance be used in perl? Explain with the help of an example.
what r the different type of function in perl ???
What's the difference between /^Foo/s and /^Foo/?
What are the various advantages and disadvantages of perl?
What does -> symbol indicates in Perl?
When do you use perl programming?