From 05345016f1c62fbd02e3eb8302f1798ccdb425e9 Mon Sep 17 00:00:00 2001 From: peterb12 Date: Tue, 17 Apr 2007 15:00:59 +0000 Subject: 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 --- crawl-ref/source/util/makedb.pl | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 crawl-ref/source/util/makedb.pl (limited to 'crawl-ref/source/util/makedb.pl') 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() { + $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; -- cgit v1.2.3-54-g00ecf