| 1 |
#!/tools/local/perl5.7.0 -w |
| 2 |
use strict; |
| 3 |
my $pat = join('|',@ARGV); |
| 4 |
|
| 5 |
my @m = glob('*.m'); |
| 6 |
my %e; |
| 7 |
|
| 8 |
foreach my $m (glob('*.m')) |
| 9 |
{ |
| 10 |
my ($what) = $m =~ /^(.*)\.m$/; |
| 11 |
open(M,"$what.m") || die "Cannot open $what.m:$!"; |
| 12 |
while (<M>) |
| 13 |
{ |
| 14 |
if (/^\s*#\s*define\s+(\w*(?:$pat)\w*)\b/o) |
| 15 |
{ |
| 16 |
warn "$what: $1\n"; |
| 17 |
my $f = $e{$what}; |
| 18 |
unless (defined $f) |
| 19 |
{ |
| 20 |
open($f,">>$what.exc") || die "Cannot open $what.exc:$!"; |
| 21 |
$e{$what} = $f; |
| 22 |
} |
| 23 |
print $f "$1\n"; |
| 24 |
} |
| 25 |
} |
| 26 |
close(M); |
| 27 |
} |
| 28 |
|
| 29 |
foreach my $f (values %e) |
| 30 |
{ |
| 31 |
close($f); |
| 32 |
} |
| 33 |
|