X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo%2FMaps.pm;h=fb42999559bddb735946db5a045dd2ddd0652703;hp=fa87c8a72ebf8fe35215bf24fbd56f3293389213;hb=ac86d926fe1f232054032ab4f36c301b8e5eccaa;hpb=eefbd51540c659904876258e2b74dbbcfda37072 diff --git a/lib/CPANPLUS/Dist/Gentoo/Maps.pm b/lib/CPANPLUS/Dist/Gentoo/Maps.pm index fa87c8a..fb42999 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Maps.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Maps.pm @@ -95,6 +95,31 @@ sub version_c2g { return $v; } +=head2 C + +Converts a perl version as you can find it in prerequisites to a Gentoo version number. + +=cut + +sub perl_version_c2g { + my ($v) = @_; + + return unless defined $v and $v =~ /^[0-9\.]+$/; + + my @parts; + if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) { + my $len = length $subversion; + if (my $pad = $len % 3) { + $subversion .= '0' x (3 - $pad); + } + @parts = ($version, $subversion =~ /(.{1,3})/g); + } else { + @parts = split /\./, $v; + } + + return join '.', map int, @parts; +} + =head1 SEE ALSO L.