Skip to content

Instantly share code, notes, and snippets.

@ishiduca
Last active January 4, 2016 08:08
Show Gist options
  • Save ishiduca/8593023 to your computer and use it in GitHub Desktop.
Save ishiduca/8593023 to your computer and use it in GitHub Desktop.
カレントディレクトリ内の .checks ファイルに書かれた項目の出現回数を表示する
#!/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;
#!/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;
}
$ 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