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 |
Why to use perl?
What is “grep” function in perl?
We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?
List the operator used in Perl?
Explain the difference between die and exit in perl?
How to find the length of an array in perl?
How to copy a file in perl?
write a script to generate n prime no.s?
Why should I use the -w argument with my Perl programs?
How do I send e-mail from a Perl/CGI program on a Unix system?
Why we use "use lib $path"?
How can you replace the characters from a string and save the number of replacements?