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 |
Explain ivalue in perl?
Explain the default scope of variables in perl?
Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.
what is the procedure to define a user define module in your perl application?
What are the different string manipulation operators in perl?
How to find out the version of PERL being installed on your LINUX machine.
Which feature of Perl provides code reusability ? Give any example of that feature.
What's the difference between /^Foo/s and /^Foo/?
What are the various uses of perl?
How to know whether a key exists or not in perl?
what r the different type of function in perl ???
What is lexical variable in perl?