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
Which feature of perl provides code reusability?
Explain perl. When do you use perl for programming?
Explain perl one-liner?
Show the use of sockets for the server and client side of a conversation?
How are parameters passed to subroutines in perl?
what are prefix dereferencer and list them out?
What does the’$_’ symbol mean?
How will you create a file in perl?
What are hashes?
Explain lexical variables.
Write a program to show the process of spawning a child process
how to extract pin_code,phone_number,year from text file using regular expressions in perl
How do you match one letter in the current locale?
Distinguish my and local?
Mention the difference between die and exit in Perl?