Skip to content

Instantly share code, notes, and snippets.

@jhthorsen
Created November 14, 2016 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhthorsen/baa15ce5afc6c332be7e9438a3bfa8bd to your computer and use it in GitHub Desktop.
Save jhthorsen/baa15ce5afc6c332be7e9438a3bfa8bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
my %u;
opendir(my $DP, '.') or die $!;
while (my $p = readdir $DP) {
opendir(my $TH, "$p/t") or next;
FILE:
while (my $t = readdir $TH) {
open my $FH, '<', "$p/t/$t" or next;
my @f;
while (<$FH>) {
push @f, qq(use lib '.';\n) if /use t::/ and !$u{$p}{$t}++;
push @f, $_;
}
if ($u{$p}{$t}) {
close $FH;
open my $FH, '>', "$p/t/$t" or die $!;
print $FH join '', @f;
}
}
if ($u{$p}) {
chdir $p;
system "git commit t -m'http://blogs.perl.org/users/todd_rinaldo/2016/11/how-removing-from-inc-is-about-to-break-cpan.html'";
chdir "..";
}
}
for my $p (sort keys %u) {
print "$p\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment