-
-
Save ishiduca/8593023 to your computer and use it in GitHub Desktop.
カレントディレクトリ内の .checks ファイルに書かれた項目の出現回数を表示する
This file contains hidden or 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/env perl | |
use strict; | |
use warnings; | |
use FindBin; | |
use File::Slurp qw(read_file); | |
my %index = (); | |
while (<*>) { | |
if (/\.checks$/) { | |
my @lines = read_file "$FindBin::Bin/$_"; | |
for (grep {$_ && $_ !~ /^#/} @lines) { | |
chomp; | |
my $circle = (split /\t/, $_)[0]; $circle = "\U$circle"; | |
$circle and | |
$index{$circle} = exists $index{$circle} ? $index{$circle} + 1 : 1; | |
} | |
} | |
} | |
print qq($_\t$index{$_}\n) for sort {$index{$a} <=> $index{$b}} keys %index; |
This file contains hidden or 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/env perl -aF'\t' -wl | |
use strict; | |
use warnings; | |
our(%index); | |
BEGIN { | |
@ARGV = grep { /\.checks$/ } <*>; | |
%index = (); | |
} | |
if ($_ && $_ !~ /^#/) { | |
local $_ = "\U$F[0]"; | |
$index{$_} = exists $index{$_} ? $index{$_} + 1 : 1; | |
} | |
END { | |
print qq($_\t$index{$_}) for sort {$index{$a} <=> $index{$b}} keys %index; | |
} |
This file contains hidden or 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
$ perl -aF'\t+' -wnl -e 'BEGIN {%index=()} $_ && $_ !~ /^#/ and ($f = "\U$F[0]") and $index{$f} = exists $index{$f} ? $index{$f} + 1 : 1; END { print qq($_\t$index{$_}) for sort {$index{$a} <=> $index{$b}} keys %index}' *.check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment