--- loncom/debugging_tools/dump_db.pl 2002/08/19 14:37:14 1.1 +++ loncom/debugging_tools/dump_db.pl 2005/03/18 19:44:38 1.4 @@ -4,7 +4,7 @@ # # dump_db.pl - dump a GDBM database to standard output, unescaping if asked to. # -# $Id: dump_db.pl,v 1.1 2002/08/19 14:37:14 matthew Exp $ +# $Id: dump_db.pl,v 1.4 2005/03/18 19:44:38 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,13 +32,16 @@ use strict; use Getopt::Long; use GDBM_File; +use Data::Dumper; +use Storable qw(freeze thaw); # # Options -my $unesc = 0; -my $help = 0; +my ($unesc,$help,$localize_times) = (0,0,0); GetOptions("unescape" => \$unesc, - "help" => \$help); + "u" => \$unesc, + "t" => \$localize_times, + "help" => \$help); # # Help them out if they ask for it @@ -51,6 +54,8 @@ database. Options: --help Display this help. --unescape Unescape the keys and values before printing them out. + -u Same as --unescape + -t Localize times when possible (human readable times) Examples: dump_db.pl mydata.db dump_db.pl mydata.db yourdata.db ourdata.db theirdata.db @@ -68,11 +73,17 @@ while (my $fname = shift) { next; } while (my ($key,$value) = each(%db)) { + if ($value =~ s/^__FROZEN__//) { + $value = thaw(&unescape($value)); + } if ($unesc) { $key = &unescape($key); - $value = &unescape($value); + $value = &unescape($value) if (! ref($value)); + } + if ($localize_times && ! ref($value)) { + $value =~ s/([0-9]{10,10})/localtime($1)/ge; } - print "$key = $value\n"; + print "$key = ".(ref($value)?Dumper($value):$value)."\n"; } untie %db; }