5 $VERSION = sprintf "%.6f", substr(q$Rev: 844 $,4)/1000000 + 5.4;
7 # CPAN::Version::vcmp courtesy Jost Krieger
11 CPAN->debug("l[$l] r[$r]") if $CPAN::DEBUG;
13 return 0 if $l eq $r; # short circuit for quicker success
16 next unless tr/.// > 1;
18 1 while s/\.0+(\d)/.$1/;
20 if ($l=~/^v/ <=> $r=~/^v/) {
23 $_ = $self->float2vv($_);
28 ($l ne "undef") <=> ($r ne "undef") ||
33 $self->vstring($l) cmp $self->vstring($r)
42 $self->vcmp($l,$r) > 0;
47 0 + ($self->vcmp($l,$r) < 0);
52 $n =~ s/^v// or die "CPAN::Version::vstring() called with invalid arg [$n]";
53 pack "U*", split /\./, $n;
56 # vv => visible vstring
61 my($mantissa) = $n =~ /\.(\d{1,12})/; # limit to 12 digits to limit
62 # architecture influence
64 $mantissa .= "0" while length($mantissa)%3;
67 $mantissa =~ s/(\d{1,3})// or
68 die "Panic: length>0 but not a digit? mantissa[$mantissa]";
71 # warn "n[$n]ret[$ret]";
77 $n =~ /^([\w\-\+\.]+)/;
79 return $1 if defined $1 && length($1)>0;
80 # if the first user reaches version v43, he will be treated as "+".
81 # We'll have to decide about a new rule here then, depending on what
82 # will be the prevailing versioning behavior then.
84 if ($] < 5.006) { # or whenever v-strings were introduced
85 # we get them wrong anyway, whatever we do, because 5.005 will
86 # have already interpreted 0.2.4 to be "0.24". So even if he
87 # indexer sends us something like "v0.2.4" we compare wrongly.
89 # And if they say v1.2, then the old perl takes it as "v12"
91 if (defined $CPAN::Frontend) {
92 $CPAN::Frontend->mywarn("Suspicious version string seen [$n]\n");
94 warn("Suspicious version string seen [$n]\n");
98 my $better = sprintf "v%vd", $n;
99 CPAN->debug("n[$n] better[$better]") if $CPAN::DEBUG;
109 CPAN::Version - utility functions to compare CPAN versions
115 CPAN::Version->vgt("1.1","1.1.1"); # 1 bc. 1.1 > 1.001001
117 CPAN::Version->vlt("1.1","1.1"); # 0 bc. 1.1 not < 1.1
119 CPAN::Version->vcmp("1.1","1.1.1"); # 1 bc. first is larger
121 CPAN::Version->vcmp("1.1.1","1.1"); # -1 bc. first is smaller
123 CPAN::Version->readable(v1.2.3); # "v1.2.3"
125 CPAN::Version->vstring("v1.2.3"); # v1.2.3
127 CPAN::Version->float2vv(1.002003); # "v1.2.3"
131 This module mediates between some version that perl sees in a package
132 and the version that is published by the CPAN indexer.
134 It's only written as a helper module for both CPAN.pm and CPANPLUS.pm.
136 As it stands it predates version.pm but has the same goal: make
137 version strings visible and comparable.
141 This program is free software; you can redistribute it and/or
142 modify it under the same terms as Perl itself.
148 # cperl-indent-level: 2