diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-28 08:48:10 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-28 08:48:10 +0000 |
commit | 96e3458b1062a70ee060d2a77677ab7c0d9e86a5 (patch) | |
tree | 3566d97334f8d4db0012307c455633f1d94ce884 /crawl-ref/source/misc | |
parent | 04d5776a5cd366a0812dec39f23a2dd8867f47c0 (diff) | |
download | crawl-ref-96e3458b1062a70ee060d2a77677ab7c0d9e86a5.tar.gz crawl-ref-96e3458b1062a70ee060d2a77677ab7c0d9e86a5.zip |
Print all entries in mon-data.h which match the given regexp
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8002 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc')
-rwxr-xr-x | crawl-ref/source/misc/grep-mon.pl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/crawl-ref/source/misc/grep-mon.pl b/crawl-ref/source/misc/grep-mon.pl new file mode 100755 index 0000000000..cc61f233d9 --- /dev/null +++ b/crawl-ref/source/misc/grep-mon.pl @@ -0,0 +1,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]/, @mons); + +print join("},", @matches) . "\n"; |