(Stolen shamelessly from here, with full permission of the author. :-)sub reduce (&@) { my $op = shift; no strict 'refs'; my $pkg = caller; local *A = local *{"$pkg\::a"}; $A = shift; local *B = local *{"$pkg\::b"}; foreach $B (@_) { $A = $op->(); } $A; }
UPDATE
D'oh. I should have read the source-code. They don't
present that in the documentation... And I wrote it
originally because someone (jcwren I think) was having
trouble running my code at Re (tilly) 1: An exercise in "That's not the way I'd do it" (TNTWIDI) because
List::Util wasn't compiling.
In reply to Re (tilly) 2: List-to-Scalar Function?
by tilly
in thread List-to-Scalar Function?
by Masem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |