]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Maps.pm
Enforce the right version of the perl dependency whenever possible
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Maps.pm
index fa87c8a72ebf8fe35215bf24fbd56f3293389213..fb42999559bddb735946db5a045dd2ddd0652703 100644 (file)
@@ -95,6 +95,31 @@ sub version_c2g {
  return $v;
 }
 
+=head2 C<perl_version_c2g $version>
+
+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<CPANPLUS::Dist::Gentoo>.