Subject: | Strange result from versioncmp |
Date: | Wed, 2 Apr 2008 16:41:22 +0200 |
To: | <bug-Sort-Versions [...] rt.cpan.org> |
From: | Matthias Schroeder <Matthias.Schroder [...] cern.ch> |
Dear perl-Sort-Version Expert(s),
using perl-Sort-Versions-1.5-1.2.el4.rf on Scientific Linux 4 (i386
machine as well as x86_64 machine), I get strange results from versioncmp.
The following demonstrates the effect:
[whatprompt?] cat ./testSortVersions.pl
#!/usr/local/bin/perl -w
#
use Sort::Versions; # perl-Sort-Versions from DAG repo
&myCompare('1.4.1', '1.4.1');
&myCompare('1.4.1', '1.4.1.el4');
&myCompare('1.4.1', '1.4.2');
&myCompare('1.4.1-12', '1.4.1-12.0.3');
&myCompare('1.4.1-12.el4', '1.4.1-12.0.3.el4');
sub myCompare(){
my ( $a, $b ) = @_;
my $rc;
$rc = versioncmp($a,$b);
if ( $rc == 1 ){
print "$a is newer than $b\n";
}
elsif( $rc == -1 ){
print "$a is older than $b\n";
}
else{
print "$a is as old as $b\n";
}
}
[whatprompt?] ./testSortVersions.pl
1.4.1 is as old as 1.4.1
1.4.1 is older than 1.4.1.el4
1.4.1 is older than 1.4.2
1.4.1-12 is older than 1.4.1-12.0.3
1.4.1-12.el4 is newer than 1.4.1-12.0.3.el4
[whatprompt?]
The result of the first four comparisons are fine with me, but I just
can not agree on the result of the fifth test.
Is that a known feature? Is it perhaps fixed already?
The perl version used is v5.8.5.
Thanks in advance for your help,
Matthias