Subject: | List::MoreUtils::first_value does not localize $_ in given/when statement |
See attached file with the test
Subject: | list_util_bug.pl |
use List::MoreUtils qw/first_value/;
use v5.10;
use Test::More;
is( test('grep'), 4, 'Grep for finding first value' );
is( test('list_more_utils'), 4, 'List::MoreUtils::first_value for finding first value' );
sub test {
my $mode = shift;
my @array = (1..10);
given ($mode) {
when ('list_more_utils') {
my $first = first_value { $_ == 4 } @array;
return $first;
}
when ('grep') {
my ($first) = grep { $_ == 4 } @array;
return $first
}
default {
die "wrong test";
}
}
}
done_testing;