in reply to Re: Dereferencing code refs with & vs. ->()
in thread Dereferencing code refs with & vs. ->()

I prefer &$thingy over $thingy->().

Aren't these apples and oranges?

sub t { my $sub=shift; $sub->(); } sub u { my $sub=shift; &$sub; } t(sub{print">@_<"},1,2,3,4,5); u(sub{print">@_<"},1,2,3,4,5); _END__ >< >1 2 3 4 5<

It's one character less (three less if you're not passing arguments), and it's more general.

More general? Im not sure I agree with that... And im not convinced about the one character less either. Id say that for the below its actually one character more. Especially given the above point that &{EXPR}() is the equivelent of EXPR->() and not &{EXPR}

do { sub { print 'foo' } }->(); ( sub { print 'bar' } )->();

That's why I also prefer:$$hash_ref{key} = $$array_ref[1];

I class that notational style as a code smell. If I have to deal with code like that the first thing I do is switch it to use the infix dereference operator. And strangely I often find that the bug I was looking for just vanishes by doing so. IOW: this style is error prone and IMO a maintenance nightmare.

---
$world=~s/war/peace/g