]> git.donarmstrong.com Git - infobot.git/blob - scripts/dbm2txt.pl
* Add vim formatting comments ( # vim:ts=4:sw=4:expandtab:tw=80 )
[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   chomp $val;
22   print "$key => $val\n";
23 }
24 dbmclose %db;
25
26 # vim:ts=4:sw=4:expandtab:tw=80