Graphs_dart/tex/task.pl

41 lines
1.5 KiB
Perl
Raw Normal View History

use locale;
use encoding "cp866";
{
print "<22><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>: "; my $folder_name=<>;
chomp($folder_name);
my @files = `chcp 866 & attrib $folder_name\\*.pl`;
if (substr($files[1],0,15) eq '<27><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>:') {
print "<22><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>.\n";
redo;
}
elsif (substr($files[1],0,15) eq '<27><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>:') {
print "<22><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .txt .\n";
last;
}
else {
foreach my $file (@files[1 .. $#files]){
my $file_name = substr($file, 11);
chomp($file_name);
open(FH,"<$file_name") or die $!;
my %hash = ();
foreach $chunk (<FH>){
my @words = $chunk =~ /([\@\%\$][a-zA-Z_0-9]+[\[\{]?)/g;
foreach my $word (@words) {
$word = "\$".substr($word, 1)
if (substr($word, 0, 1) eq '@' &&
substr($word, -1) eq '[');
$word = "\$".substr($word, 1)."["
if (substr($word, 0, 1) eq '@');
$word = "\$".substr($word, 1)."{"
if (substr($word, 0, 1) eq '%');
$hash{$word}++;
};
};
my @xs = keys %hash;
print @xs;
close(FH);
my $ans = scalar(@xs);
print "$file_name : $ans\n";
}
}
}