diff options
author | peterb12 <peterb12@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-17 15:00:59 +0000 |
---|---|---|
committer | peterb12 <peterb12@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-17 15:00:59 +0000 |
commit | 05345016f1c62fbd02e3eb8302f1798ccdb425e9 (patch) | |
tree | acba17fc138e5bf33b439df6bad6b9f3b086c1be /crawl-ref/source/util/makedb.pl | |
parent | 77ea6aed5bf59f1c8deb2c47dd7d222494f25571 (diff) | |
download | crawl-ref-05345016f1c62fbd02e3eb8302f1798ccdb425e9.tar.gz crawl-ref-05345016f1c62fbd02e3eb8302f1798ccdb425e9.zip |
First cut at db/flat text file based descriptions.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1331 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util/makedb.pl')
-rwxr-xr-x | crawl-ref/source/util/makedb.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/crawl-ref/source/util/makedb.pl b/crawl-ref/source/util/makedb.pl new file mode 100755 index 0000000000..4e1c6597a7 --- /dev/null +++ b/crawl-ref/source/util/makedb.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +use DB_File; + +open(TEXT,"../dat/descriptions.txt"); +unlink("../dat/descriptions.db"); +tie %descriptions, 'DB_File', "../dat/descriptions.db"; + +my $state = 0; +my $title = ""; +my $entry = ""; +while(<TEXT>) { + $thisLine = $_; + if ($thisLine =~ /^#/) { + # It's a comment. continue. + next; + } + if ($thisLine =~ /^%%%%/) { + $state=1; + # Push existing entry, if any, to the database. + if ($title ne "") { + $descriptions{"$title"} = "$entry"; + # Clear and set up for next run. + $title = ""; + $entry = ""; + } + next; + } + if (1 == $state) { + # Lowercase the title, to canonicalize the key. + $title = lc($thisLine); + chomp($title); + # print ("I just read $title\n"); + $state++; + next; + } + if (2 == $state) { + $entry .= $thisLine; + next; + }; + +} +$descriptions{"$title"} = "$entry"; + +while (($k, $v) = each %descriptions) + { print "$k -> $v\n" } + + +untie %descriptions; |