For the most part (as usual) I agree with tilly here.
wantarray is generally the best way to do things, that gives you ultimate flexibility. And there are definitely times when returning a list instead of a hashref is good.
However, I have three minor quibbles.
- I'm not convinced by the argument that dereferencing can eventually add up to be costly enough. Use aliasing, and you really get the best of both worlds.
sub f { %hash = (1,2,3,4); return \%hash }
*my_hash = f();
$my_hash{1}++;
No dereffing necessary, you have the speed of passing a reference combined with the speed of direct hash access.
- Refcounting is garbage collection. It may do some things suboptimally, but it's no less garbage collection than mark-and-sweep, etc.
- Perl is not an interpreted language.
-dlc (sans acidic tone ;-) )