Subject: | pairwise issues warnings about $a and $b being used only once. |
Warnings should probably be suppressed regarding "used only once" for $a
and $b within the code block of pairwise. Here is an example test that
triggers two warnings:
BEGIN{ $ENV{LIST_MOREUTILS_PP} = 1; }
use strict;
use warnings;
use Test::More tests => 2;
use Test::NoWarnings;
use List::MoreUtils qw( pairwise );
diag "\n\$ENV{LIST_MOREUTILS_PP} = ", $ENV{LIST_MOREUTILS_PP};
diag 'List::MoreUtils version: ', $List::MoreUtils::VERSION, "\n\n";
{
my @left = qw( one two three );
my @right = ( 1, 2, 3, );
my @res = pairwise { "$a => $b" } @left, @right;
is( join( ' ', @res ), 'one => 1 two => 2 three => 3', "pairwise
test." );
}
Here is the output I get:
1..2
#
# $ENV{LIST_MOREUTILS_PP} = 1
# List::MoreUtils version: 0.33
#
ok 1 - pairwise test.
not ok 2 - no warnings
# Failed test 'no warnings'
# at C:/strawberry/perl/vendor/lib/Test/NoWarnings.pm line 38.
# There were 2 warning(s)
# Previous test 0 ''
# Name "main::b" used only once: possible typo at mytest.pl line 18.
# at mytest.pl line 18
#
# ----------
# Previous test 0 ''
# Name "main::a" used only once: possible typo at mytest.pl line 18.
# at mytest.pl line 18
#
# Looks like you failed 1 test of 2.
This may be an issue for other functions that also use $a and $b, though
I didn't specifically test them too.
Perl version 5.14.2. Tested on win32/strawberry, and Ubuntu Linux.
Dave