Don't ask to ask, just ask | |
PerlMonks |
Re: Relative Merits of Referencesby clinton (Priest) |
on May 11, 2006 at 14:19 UTC ( [id://548717]=note: print w/replies, xml ) | Need Help?? |
Why do you think that that construct is illegal? I tried this code in perl 5.8.7 and it works without any warnings.
And it prints
However it seems an odd way to do it when you could just say :
I benchmarked the two versions, and the first %$a=() is 50% slower than the second ($a={}). Regarding the difference between $h{name} versus $h->{name}, there is a slight speed difference (10%), because the second version first needs to dereference $h before doing the lookup, but it is so blazingly fast that I wouldn't worry about it. (Tested on a small hash - not sure for bigger hashes) Rather just use whatever is easier to read, as there are bound to be other bottlenecks that make much more difference to your code's performance.
In Section
Seekers of Perl Wisdom
|
|