| 1 |
#!/usr/local/bin/perl -w |
| 2 |
|
| 3 |
use File::Find; |
| 4 |
|
| 5 |
%words = (); |
| 6 |
|
| 7 |
open(KEY,"pTk/Methods.def") || die "Cannot open pTk/Methods.def:$!"; |
| 8 |
while (<KEY>) |
| 9 |
{ |
| 10 |
if (/\(\("(.*)",NULL\)\)/) |
| 11 |
{ |
| 12 |
my @words = split(/","/,$1); |
| 13 |
my $word; |
| 14 |
foreach $word (@words) |
| 15 |
{ |
| 16 |
next if ($word =~ /^[A-Z]/); |
| 17 |
unless (exists $words{$word}) |
| 18 |
{ |
| 19 |
$words{$word} = 1; |
| 20 |
} |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
close(KEY); |
| 25 |
|
| 26 |
$words = '('.join('|',keys %words).')'; |
| 27 |
|
| 28 |
|
| 29 |
sub match |
| 30 |
{ |
| 31 |
while (/sub\s+\b(${words}[A-Za-z]+|[A-Za-z]+${words})\b/go) |
| 32 |
{ |
| 33 |
unless (exists $word{$1}) |
| 34 |
{ |
| 35 |
print STDERR "$1 '$2/$3'\n"; |
| 36 |
$word{$1} = [] |
| 37 |
} |
| 38 |
push(@{$word{$1}},"${File::Find::name}:$."); |
| 39 |
} |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|
| 43 |
sub wanted |
| 44 |
{ |
| 45 |
$File::Find::prune = 0; |
| 46 |
if (-T $_ && !/%$/) |
| 47 |
{ |
| 48 |
if (/\.pm$/) |
| 49 |
{ |
| 50 |
local $file = ($_); |
| 51 |
local ($_); |
| 52 |
open($file,"<$file") || die "Cannot open $file:$!"; |
| 53 |
while (<$file>) |
| 54 |
{ |
| 55 |
last if &match; |
| 56 |
} |
| 57 |
close($file); |
| 58 |
} |
| 59 |
} |
| 60 |
elsif (-d $_) |
| 61 |
{ |
| 62 |
$File::Find::prune = 1 if (/^(blib|Pod|HTML)$/); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
@ARGV = '.' unless (@ARGV); |
| 67 |
|
| 68 |
find(\&wanted,@ARGV); |
| 69 |
|
| 70 |
foreach (sort keys %word) |
| 71 |
{ |
| 72 |
print "$_:",join(' ',@{$word{$_}}),"\n"; |
| 73 |
} |