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 |
How are parameters passed to subroutines in perl?
Explain about the applications of perl?
Explain the functioning of conditional structures in perl.
What are the arguments and what do they mean in perl programming?
In Perl, there are some arguments that are used frequently. What are that arguments and what do they mean?
What is an interpolation in perl?
Explain perl. What are the advantages of programming in perl?
Which functions in Perl allows you to include a module file or a module and what is the difference between them?
How to close a file in perl?
How do I read command-line arguments with Perl?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
Enlist the advantages of using c over perl?