1#!/usr/bin/env perl
2use DB_File;
3
4open(TEXT,"../dat/descriptions.txt");
5unlink("../dat/descriptions.db");
6tie %descriptions, 'DB_File', "../dat/descriptions.db";
7
8my $state = 0;
9my $title = "";
10my $entry = "";
11while (<TEXT>)
12{
13    $thisLine = $_;
14    if ($thisLine =~ /^#/)
15    {
16       # It's a comment.  continue.
17       next;
18    }
19    if ($thisLine =~ /^%%%%/)
20    {
21        $state=1;
22        # Push existing entry, if any, to the database.
23        if ($title ne "")
24        {
25            $descriptions{"$title"} = "$entry";
26            # Clear and set up for next run.
27            $title = "";
28            $entry = "";
29        }
30        next;
31    }
32    if (1 == $state)
33    {
34        # Lowercase the title, to canonicalize the key.
35        $title = lc($thisLine);
36        chomp($title);
37        #        print ("I just read $title\n");
38        $state++;
39        next;
40    }
41    if (2 == $state)
42    {
43        $entry .= $thisLine;
44        next;
45    };
46
47}
48$descriptions{"$title"} = "$entry";
49
50while (($k, $v) = each %descriptions)
51   { print "$k -> $v\n" }
52
53
54untie %descriptions;
55