]> git.donarmstrong.com Git - infobot.git/blobdiff - scripts/dbm2txt.pl
avoid reassigning to temp upon decode_utf8
[infobot.git] / scripts / dbm2txt.pl
index 0cfb10fa54eceaa3e1db88b72528be086c7a4857..9a2b299fa5f5a8d7513b753473c5d4dc3403d5ec 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/perl -w
 
 use strict;
-
-if (!scalar @ARGV) {
+use DB_File;
+if ( !scalar @ARGV ) {
     print "Usage: dbm2txt <whatever dbm>\n";
     print "Example: dbm2txt.pl factoids\n";
     exit 0;
@@ -15,10 +15,12 @@ if (0) {
     openDB();
 }
 
-dbmopen(%db,$dbname,0444) or die "error: cannot open db.\n";
-foreach (keys %db) {
-  next if /=>/;                # skip the key if it contains the delimiter.
-
-  print "$_ => $db{$_}\n";
+dbmopen( %db, $dbfile, 0644 ) or die "error: cannot open db. $dbfile\n";
+my ( $key, $val );
+while ( ( $key, $val ) = each %db ) {
+    chomp $val;
+    print "$key => $val\n";
 }
 dbmclose %db;
+
+# vim:ts=4:sw=4:expandtab:tw=80