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 to make the following assignment, as arrayreference assignment ? my $arr_ref='[1,2,3,4,4,'elem']';
How would you trap error occurred in the perl program/file?
what are the steps involved in reading a cgi script on the server?
What is perl? What is the basic command to print a string in perl?
What are the options that can be used to avoid logic errors in perl?
What are the advantages and disadvantages of perl language?
Explain the various characteristics of perl.
Explain strftime() function in perl?
What is the function of virtual documents in cgi programs?
How can you use Perl warnings and what is the importance to use them?
Write a script for 'count the no.of digits using regular expressions in perl..
Explain the arguments for perl interpreter.