Subject: | Non-numeric value warning for 'use 5.010_000;' |
This problem appeared when a file, tools/dev/branch_status.pl, was
recently added to the Parrot distribution. The program, written (unlike
most code in Parrot) in Perl 5.10, starts with this code:
use 5.010_000;
use strict;
use warnings;
use feature();
When we run this file through our t/codingstd/perlcritic.t, we get the
following output:
$ perl t/codingstd/perlcritic.t tools/dev/branch_status.pl
1..1
Argument "5.010_000" isn't numeric in subroutine entry at
/usr/local/lib/perl5/site_perl/5.10.0/Perl/Critic/Document.pm line 139.
ok 1 - Test::Perl::Critic for "tools/dev/branch_status.pl"
Examining Perl::Critic::Document in the specified area, I see this code:
sub highest_explicit_perl_version {
my ($self) = @_;
my $highest_explicit_perl_version =
$self->{_highest_explicit_perl_version};
if ( not exists $self->{_highest_explicit_perl_version} ) {
my $includes = $self->find( \&_is_a_version_statement );
if ($includes) {
$highest_explicit_perl_version =
max map { version->new( $_->version() ) } @{$includes};
}
#...
}
Line 139 is: max map { version->new( $_->version() ) } @{$includes};
List::Util::max() is documented as follows:
max LIST
Returns the entry in the list with the highest numerical
value. If the list is empty then "undef" is returned.
I suspect that 'version->new' is somehow delivering a non-numeric value
to 'max'.
However, when I rewrite the version specification as:
use v5.10.0;
... our coding standards test passes.
Is this a bug in Perl::Critic::Document's use of 'max' or 'version' --
or are we doing something wrong?
Thank you very much.
Jim Keenan