[sf-perl] Prototypes, List::MoreUtils and subroutine references, OH MY!

George Hartzell hartzell at alerce.com
Thu Mar 28 17:16:49 PDT 2013


I have a bunch of subs that are line for line identical, except that
they use a different one of List::MoreUtils qw(any all) [etc...].

No problem, I thought, I'll just create a generic version and pass in
a reference to the list function that I'd like to use.

Given something like this

  my $any = \&any;

I've discovered that I need to call it passing in a code ref as the
first item in a list:

  &$any( sub { ... }, @things );

where when I call any directly I pass in a block

  any { ...} @things;

It seems that somehow the prototype magic doesn't travel along with
the code ref.

Is this the way it is or am I screwing something up and getting lucky?

g.


More information about the SanFrancisco-pm mailing list