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 are the steps involved in reading a cgi script on the server?
Which functions in perl allows you to include a module file.
What is 'commit' command in perl?
Can inheritance be used in perl? Explain with the help of an example.
How to replace perl array elements?
What are the arguements we normally use for perl interpreter?
What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability?
How to implement a stack in Perl?
What does `$result = f() .. g()' really return?
How can I display all array element in which each element will display on next line in perl ?
Why do you program in Perl?
Explain what is STDIN, STDOUT and STDERR?