Skip Menu |

This queue is for tickets about the Perl-Version CPAN distribution.

Report information
The Basics
Id: 132481
Status: rejected
Priority: 0/
Queue: Perl-Version

People
Owner: Nobody in particular
Requestors: lubos [...] kolouch.net
Cc:
AdminCc:

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



Subject: 1.2.1 is not > 1.2_1
use strict; use warnings; use Perl::Version; sub compare_versions { my ($ver1, $ver2) = @_; my $v1 = version->new($ver1); my $v2 = version->new($ver2); return $v1 <=> $v2; } # TESTS use Test::More; is(compare_versions('0.1','1.1'),-1); is(compare_versions('2.0','1.2'),1); is(compare_versions('1.2','1.2_5'),-1); is(compare_versions('1.2.1','1.2_1'),1); is(compare_versions('1.2.1','1.2.1'),0); ok 1 ok 2 ok 3 not ok 4 # Failed test at ch-2.pl line 50. # got: '-1' # expected: '1' ok 5
You're using the version.pm module (a different beast from Perl::Version) to compare your strings. When I change it to use Perl::Version, all the tests pass: sub compare_versions { my ($ver1, $ver2) = @_; my $v1 = Perl::Version->new($ver1); my $v2 = Perl::Version->new($ver2); return $v1 <=> $v2; }