blob: 4e1c6597a75dec7018c41008ee03627a27774f73 (
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
|
#!/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;
|