X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Fgengentooisms;fp=samples%2Fgengentooisms;h=ca69b2360d42c43c547e6d5014c44bc97e260d80;hb=7e2aca98057c17b7728aa3028a07dacd2fdd0d62;hp=d7659ef547260e352cf8b081bd11b467372b600e;hpb=5ca9d34b87636383084fd4bb2ac6ef3b13999e7b;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/samples/gengentooisms b/samples/gengentooisms index d7659ef..ca69b23 100755 --- a/samples/gengentooisms +++ b/samples/gengentooisms @@ -8,9 +8,13 @@ use strict; use warnings; use Fatal; +use Cwd qw/cwd/; use List::Util qw/max/; +use File::Copy qw/copy/; use constant PORTAGE => '/usr/portage'; +use constant TARGET => 'lib/CPANPLUS/Dist/Gentoo/Maps.pm'; +use constant BACKUP => TARGET . '.bak'; my %gentooism; @@ -25,6 +29,8 @@ my %where = ( 'PDF-Create' => 0, ); +my $cwd = cwd(); + for my $category (qw/perl-core dev-perl/) { my $dir = PORTAGE . '/' . $category; chdir $dir; @@ -65,11 +71,23 @@ for my $category (qw/perl-core dev-perl/) { } } +chdir $cwd; + +copy TARGET, BACKUP or die "copy failed: $!"; + +open my $src, '<', BACKUP; +open my $dst, '>', TARGET; + my $max = max map length, keys %gentooism; +SRC: while (<$src>) { + print $dst $_; + if (/^__DATA__$/) { + printf $dst "%s%s %s\n", $_, (' ' x ($max - length)), $gentooism{$_} + for sort keys %gentooism; + last SRC; + } +} + print STDERR +(keys %gentooism) . " gentooisms found\n"; -print "our %gentooism = (\n"; -printf " '%s'%s => '%s',\n", $_, (' ' x ($max - length)), $gentooism{$_} - for sort keys %gentooism; -print ");\n";