]> git.donarmstrong.com Git - infobot.git/blob - scripts/dbm2txt.pl
- patch from tim riker.
[infobot.git] / scripts / dbm2txt.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use DB_File;
5 if (!scalar @ARGV) {
6     print "Usage: dbm2txt <whatever dbm>\n";
7     print "Example: dbm2txt.pl factoids\n";
8     exit 0;
9 }
10
11 my $dbfile = shift;
12 my %db;
13 if (0) {
14     require "src/Factoids/db_dbm.pl";
15     openDB();
16 }
17
18 dbmopen(%db, $dbfile, 0644) or die "error: cannot open db. $dbfile\n";
19 my ($key, $val);
20 while (($key, $val) = each %db) {
21   next if /=>/;         # skip the key if it contains the delimiter.
22   chomp $val;
23   print "$key => $val\n";
24 }
25 dbmclose %db;