Subject: | reduce/pairwise combo doesn't work |
Hi there:
I'm forwarding this bug on behalf of a Debian user. It was originally
filed as: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487262
The following is from the original bug report:
Package: liblist-moreutils-perl
Version: 0.21-1
Severity: normal
File: /usr/lib/perl5/List/MoreUtils.pm
It'd be nice if this worked:
use List::Util qw/reduce/;
use List::MoreUtils qw/pairwise/;
use strict;
my $data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
my $total = reduce { [ pairwise { $a + $b } @$a, @$b ] } @$data;
print join(", ", @$total), "\n";
expected:
12, 15, 18
got:
Can't use string ("3") as an ARRAY ref while "strict refs" in use at
/tmp/foo.pl line 5.
It looks like the localization of $a and $b isn't working correctly, and
reduce's $a and $b are being messed up. I tried RTFS, but I don't
understand why it's happening.
I tried with perl 5.10.0-10 (debian testing), and same error.