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 is the different between array and hash in perl programming?
What is the tk module?
Explain perl. What are the advantages of programming in perl?
Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?
How many data types are there in perl?
What are the various advantages and disadvantages of perl?
you are required to replace a char in a string and store the number of replacements. How would you do that?
What is boolean context?
What is caller function in perl?
What is the difference between localtime() and gmtime() functions?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
how to search a unique pattern in a file by using perl hash map function ??? plz answer me