There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re: Relative Merits of References
by clinton
|
|