Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Created April 19, 2013 06:11
Show Gist options
  • Save hyuki0000/5418450 to your computer and use it in GitHub Desktop.
Save hyuki0000/5418450 to your computer and use it in GitHub Desktop.
Try to find ruby-ed keywords that are not indexed from LaTeX files.
# ruby.pl
# カレントディレクトリの *.tex から、
# ruby{A}{B}とindex{A@B}とindex{A}を探し、
# indexされていないと思われるrubyを表示する。
use strict;
use warnings;
my %index;
my %ruby;
for my $filename (glob("*.tex")) {
open(FILE, $filename) or die;
while (<FILE>) {
if (/ruby{(.+?)}{(.+?)}/) {
$ruby{$1}++;
$ruby{$2}++;
}
if (/index{(.+?)\@(.+?)}/) {
$index{$1}++;
$index{$2}++;
} elsif (/index{(.+?)}/) {
$index{$1}++;
}
}
close(FILE);
}
for my $key (sort keys %ruby) {
if (not $index{$key}) {
print $key, "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment