use strict;
use feature "switch";
open my $outfh, '>:encoding(utf8)', 'user-list.txt';
my %NOT_COLLECTED;
my @UNCLASSIFIED_FILE;
sub print_not_collected {
print $outfh "-----------------------------------------\n";
for (keys %NOT_COLLECTED) {
print $outfh $_ . ' ' . join(' ', keys %{+{map +($_ => undef), @{$NOT_COLLECTED{$_}}}}) . "\n";
}
print $outfh "-----------------------------------------\n";
print $outfh join "\n", @UNCLASSIFIED_FILE;
close($outfh);
exit(0);
}
use sigtrap 'handler' => \&print_not_collected, qw(INT QUIT);
my @tmp_PIV;
while(<user-pivot-*.txt>) {
my ($class) = /\d+/g;
open my $ph, "<:encoding(utf8)", $_;
push @tmp_PIV, \%{+{map {/(.*)/; $1=>$class} grep /.+/, <$ph>}};
}
my %DUP;
for my $i (0..$#tmp_PIV-1) {
for my $j ($i+1..$#tmp_PIV) {
for (keys %{$tmp_PIV[$i]}) {
$DUP{$_}{$tmp_PIV[$i]{$_}} = $tmp_PIV[$j]{$_} if exists $tmp_PIV[$j]{$_};
}
}
}
for my $name (keys %DUP) {
for my $i (keys %{$DUP{$name}}) {
print "$name $i ${DUP{$name}{$i}}\n";
}
}
die "Duplicated class entries." unless (keys %DUP)==0;
my %PIV_EQ_CLASS;
for (@tmp_PIV) {
%PIV_EQ_CLASS = (%PIV_EQ_CLASS, %{$_});
}
my %NOT_PIV;
open my $nph, "<:encoding(utf8)", "user-not-pivot.txt";
%NOT_PIV = %{+{map {/(.*)/; $1=>0} grep /.+/, <$nph>}};
$NOT_PIV{''} = 0; # we don't want to consider blank pivots
my @tmp = grep exists($NOT_PIV{$_}), keys %PIV_EQ_CLASS;
die 'Ambiguity pivot not pivot: ' . join "\n", @tmp unless @tmp==0;
local $/ = undef;
while(glob "HTML/**") {
print "$_\n";
open my $fh, "<:encoding(utf8)", $_;
my $fname = $_;
my $text = <$fh>;
$text =~ /<!-- Parsed text .*-->\n/g;
my @tmp = $text =~ /<!-- .* -->/g;
my $text2 = join '', map {; s/<!-- //; s/ -->//; $_; } @tmp;
$text2 =~ s/- ( *)(?=-)/-$1/g;
my @FILE_CLASS;
for ($text2 =~ /FriendlyName="(.*?)"/g) {
push @FILE_CLASS, $PIV_EQ_CLASS{$_} if exists $PIV_EQ_CLASS{$_};
push @{$NOT_COLLECTED{$_}}, $fname if not exists $PIV_EQ_CLASS{$_} and not exists $NOT_PIV{$_};
}
print $outfh $fname . ' ' . join(' ', keys %{+{map +($_ => undef), @FILE_CLASS}}) . "\n" unless @FILE_CLASS==0;
push @UNCLASSIFIED_FILE, $fname if @FILE_CLASS==0;
}
print_not_collected;
No hay comentarios:
Publicar un comentario