Perl::Version vs version confusion
Version numbers should be boring and modules such as version and Perl::Version should be boring too.
Yet they are confusing me.
examples/sort_version_confusion.pl
use strict; use warnings; use 5.010; use Perl::Version; use version; say "Perl::Version: $Perl::Version::VERSION"; say "version: $version::VERSION"; my @versions = ( '5.11', 'v5.11', '5.011', '5.11'); say '----'; my @sorted = sort { Perl::Version->new( $a ) <=> Perl::Version->new( $b ) } @versions; for my $s (@sorted) { say $s; } say '----'; my @other = sort { version->parse( $a ) <=> version->parse( $b ) } @versions; for my $s (@other) { say $s; }
And the output
Perl::Version: 1.013 version: 0.9912 ---- 5.11 v5.11 5.011 5.11 ---- v5.11 5.011 5.11 5.11
I am not yet sure which module is confused, but I am, for sure.
It seems that Perl::Version thinks that 5.11 and v5.11 are the same while version thinks they are different.
Not only that, but Perl::Version seems to thin 5.11 equals to 5.011. I am fairly sure that should not be the case.
examples/version_compare_confusion.pl
use strict; use warnings; use 5.010; use Perl::Version; use version; say Perl::Version->new('5.11') == Perl::Version->new('v5.11'); # 1 say version->parse('5.11') == version->parse('v5.11'); # say Perl::Version->new('5.011') == Perl::Version->new('v5.11'); # 1 say version->parse('5.011') == version->parse('v5.11'); # 1 say Perl::Version->new('5.011') == Perl::Version->new('5.11'); # 1 say version->parse('5.011') == version->parse('5.11'); # 0
Published on 2015-12-04