go ahead... be a heretic | |
PerlMonks |
Re: Reference curiosity?by kvale (Monsignor) |
on Apr 23, 2006 at 17:32 UTC ( [id://545138]=note: print w/replies, xml ) | Need Help?? |
In the first case, %hash is still in scope within the subrotuine, and so is still visible and is used in the print statement. In the second case, %hash has not been defined by the time the print statement occurs, so won't work.
Please note that $hash and %hash are different variables in perl. If you want to access hash element A with hash reference $hash, you would use $hash->{A}. See perlref for details. Update: fixed a typo. -Mark
In Section
Seekers of Perl Wisdom
|
|