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 are the different types of perl operators?
What is the Common Gateway Interface?
Explain the difference between "my" and "local" variable scope declarations. ?
What is perl scripting?
What does file test operators do in perl?
you are required to replace a char in a string and store the number of replacements. How would you do that?
Perl regular expressions are greedy" what does this mean?
What is perl? What is the basic command to print a string in perl?
Explain '->' in perl?
How to determine strings length in perl?
What are the different instances used in cgi overhead?
How to read multi lines from a file in perl?