blob: cb3538768b6f9e33dacc2f5b60ccc3a76ca3a0b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/usr/bin/perl -w
use strict;
unless(@ARGV == 1)
{
die("usage: grep-mon.pl <pattern>\n");
}
my $data_file;
if (-e "mon-data.h")
{
$data_file = "mon-data.h";
}
elsif (-e "../mon-data.h")
{
$data_file = "../mon-data.h";
}
else
{
die("Can't find 'mon-data.h'\n");
}
unless (open(FILE, "<$data_file"))
{
die("Couldn't open '$data_file' for reading: $!\n");
}
my $line;
while(<FILE>)
{
$line = $_;
last if ($line =~ /static monsterentry mondata/);
}
unless ($line =~ /static monsterentry mondata/)
{
die("Couldn't find mondata array.\n");
}
# Slurp in the rest of it.
undef($/);
my $content = <FILE>;
close(FILE);
my @mons = split(/^},/m, $content);
my @matches = grep(/$ARGV[0]/s, @mons);
print join("},", @matches) . "\n";
|