As chip pointed out to me at one point, & is trying to use $hash as a code reference, and not looking at the full $hash{test} to get the desired result. The braces explicitly define the coderef to be evaluated.
I always use braces to dereference things as a general rule. It's easier to read and helps avoid problems like the above :-) I've also found that this is a nice way to work with code refs (and any ref in general):
$dog = $hash_ref->{dog}; $apple = $ary_ref->[3]; $car = $code_ref->('Ford');
A quick $hash{test}->(..params..) should do the trick, since the arrow operator is smarter (a more flexible binder) than '&'. You may or may not find it easier to read than &{$hash{test}}(..params..).
Alakaboo
(UPDATE: Ugh, both merlyn and tilly beat me to the punch. Drat!!)
In reply to RE: hash o' refs
by mwp
in thread hash o' refs
by Adam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |