http://www.perlmonks.org?node_id=440433


in reply to Re: Array iterator factory
in thread Array iterator factory

Note that &$iter() is just fine (it has none of the problems of &$iter;) and is even better than $iter->() in that it works on fairly old versions of Perl (though enough time has passed since the $iter->() syntax was introduced that few need to worry much about supporting versions of Perl that predate it).

It seems that 'everyone' focuses on the & as being the problem and never mention that ampersand with parens is okay, sometimes even an advantage. Note that the both $iter->() and &$iter() ignore prototypes (since such are only enforced at compile time, a time during which perl doesn't know what function $iter might point to) and neither can be used directly with built-in functions so not even the difference between func() and &func() apply between &$iter() and $iter->().

(tye)Re: A question of style covers much of & and () and calling subroutines.

- tye