X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDOM%2FTiny%2F_Collection.pm;h=547946c9f1c7ade78a2a28d93ac9467db01c877b;hb=b1ec524b3b6c75361f548d73cfda0282db607a9d;hp=44a1741c796cc6ae7da24d24054a563399afceb0;hpb=ba90904812100c8408eaa44df5886241e7c13319;p=catagits%2FDOM-Tiny.git diff --git a/lib/DOM/Tiny/_Collection.pm b/lib/DOM/Tiny/_Collection.pm index 44a1741..547946c 100644 --- a/lib/DOM/Tiny/_Collection.pm +++ b/lib/DOM/Tiny/_Collection.pm @@ -8,7 +8,7 @@ use Scalar::Util 'blessed'; use constant REDUCE => ($] >= 5.008009 ? \&List::Util::reduce : \&_reduce); -our $VERSION = '0.002'; +our $VERSION = '0.004'; sub new { my $class = shift; @@ -116,16 +116,15 @@ sub _reduce (&@) { no strict 'refs'; - local(*{$caller."::a"}) = \my $a; - local(*{$caller."::b"}) = \my $b; + local (*{"${caller}::a"}, *{"${caller}::b"}) = (\my $x, \my $y); - $a = shift; - foreach (@_) { - $b = $_; - $a = &{$code}(); + $x = shift; + foreach my $e (@_) { + $y = $e; + $x = $code->(); } - $a; + $x; } sub _ref { ref $_[0] eq 'ARRAY' || blessed $_[0] && $_[0]->isa(__PACKAGE__) }