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
How can you create anonymous subroutines?
Can inheritance be used in perl? Explain with the help of an example.
How can the user execute a long command repeatedly without typing it again and again?
What are some common methods to all handles in perl?
What is the different between array and hash in perl programming?
What are the steps involved when the cgi program starts running?
List the prefix dereferencer in Perl.
What is perl unshift array function?
How to do comment in perl?
Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)
Write a program to show the process of spawning a child process
Write an example explaining the use of symbol tables.
What are arrays in perl?
What are prefix dereferencer? List them.
List all the features of perl programming?