Last active
November 14, 2019 20:07
-
-
Save marked/fae8f25626d6f7117a9313c71cb57cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use autodie; | |
my @lines = <>; | |
chomp @lines; | |
my %adjadj; | |
foreach my $l (@lines) { | |
my ($combo, $reduc) = split / /, $l ; | |
if ($adjadj{$reduc}) { | |
push(@{$adjadj{$reduc}}, ($combo)); | |
} else { | |
$adjadj{$reduc} = [ $combo ]; | |
} | |
} | |
my %dirs; | |
foreach my $aa (keys(%adjadj)) { | |
$aa =~ /([A-Z][a-z]+)([A-Z][a-z]+)/; | |
my ($a1, $a2) = ($1, $2); | |
if ( ! $dirs{$a1}) { | |
system "mkdir $a1"; | |
$dirs{$a1} = 1; | |
} | |
open my $fh, ">", "$a1/$a2"; | |
my $js = join "\n", sort(@{$adjadj{$aa}}); | |
print $fh "$js\n"; | |
close $fh; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment