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 functions in perl allows you to include a module file. State their differences.
Explain what is perl language?
you are required to replace a char in a string and store the number of replacements. How would you do that?
What does localtime() do in perl?
What are stdin, stdout and stderr?
How to change a directory in perl?
How will you create a file in perl?
What is the use of -n and -p options?
what is Chop & Chomp function does?
How to determine strings length in perl?
What can be done for efficient parameter passing in perl? Explain.
How will you open a file in a write-only mode in perl?
Which operator in perl is used for the concatenation of two strings?
What is perl pop array function?
Explain perl. When do you use perl for programming?