in reply to Re (tilly) 2: List-to-Scalar Function?
in thread List-to-Scalar Function?
Although if the XS compiles and loads, this code is not used.use vars qw($a $b); sub reduce (&@) { my $code = shift; return shift unless @_ > 1; my $caller = caller; local(*{$caller."::a"}) = \my $a; local(*{$caller."::b"}) = \my $b; $a = shift; foreach (@_) { $b = $_; $a = &{$code}(); } $a; }
-- Randal L. Schwartz, Perl hacker
|
|---|