Skip Menu |

This queue is for tickets about the CPANPLUS CPAN distribution.

Report information
The Basics
Id: 14106
Status: resolved
Priority: 0/
Queue: CPANPLUS

People
Owner: Nobody in particular
Requestors: kwilliams [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] avoid warning with beta module versions
Hi, When CPANPLUS::inc::import() is used for a module that's already installed on the user's machine in "beta", i.e. the $VERSION contains underscores, it will emit a bunch of warnings: Argument "1.23_45" isn't numeric in numeric comparison (<=>) at /Library/Perl/5.8.1/ CPANPLUS/inc.pm line 383, <> line 18. This occurs even when the module declares its beta version properly (containing an underscore for the PAUSE indexer, but none for API users) like so: $VERSION = '1.23_45'; $VERSION = eval $VERSION; The attached patch fixes the problem by normalizing any versions (removing underscores) prior to numerical comparison. Any other stray characters, like letters or other symbols, will still produce the same warning, which I figured was probably the right behavior. -Ken
--- /Library/Perl/5.8.1/CPANPLUS/inc.pm Tue May 3 08:54:41 2005 +++ /Users/ken/lib/CPANPLUS/inc.pm Wed Aug 10 21:43:24 2005 @@ -381,7 +381,7 @@ ### or otherwise, the one not bundled ### or otherwise the newest my @sorted = sort { - ($b->[0] <=> $a->[0]) || + vcmp($b->[0], $a->[0]) || ($Cache{$interesting} ?($b->[2] eq $Cache{$interesting}->[0][2]) <=> ($a->[2] eq $Cache{$interesting}->[0][2]) @@ -395,7 +395,7 @@ ."'$sorted[0][2]' with version '$sorted[0][0]'\n" if $DEBUG; - if( $check_version and not ($sorted[0][0] >= $map->{$module}) ) { + if( $check_version and not (vcmp($sorted[0][0], $map->{$module}) >= 0) ) { warn __PACKAGE__ .": Cannot find high enough version for " ."'$module' -- need '$map->{$module}' but " ."only found '$sorted[0][0]'. Returning " @@ -428,6 +428,12 @@ return $sorted[0][1]; } ); } +} + +sub vcmp { + my ($x, $y) = @_; + s/_//g foreach $x, $y; + return $x <=> $y; } =pod
Thanks, applied with minor whitespace fixes @12163