--- loncom/debugging_tools/dump_db.pl 2005/03/18 21:36:49 1.5 +++ loncom/debugging_tools/dump_db.pl 2006/06/19 09:36:22 1.6 @@ -4,7 +4,7 @@ # # dump_db.pl - dump a GDBM database to standard output, unescaping if asked to. # -# $Id: dump_db.pl,v 1.5 2005/03/18 21:36:49 albertel Exp $ +# $Id: dump_db.pl,v 1.6 2006/06/19 09:36:22 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,6 +34,8 @@ use Getopt::Long; use GDBM_File; use Data::Dumper; use Storable qw(thaw); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; # # Options @@ -67,12 +69,13 @@ END # # Loop through ARGV getting files. while (my $fname = shift) { - my %db; - if (! tie(%db,'GDBM_File',$fname,&GDBM_READER(),0640)) { + my $dbref=&LONCAPA::locking_hash_tie($fname,&GDBM_READER()); + + if (!$dbref) { warn "Unable to tie to $fname"; next; } - while (my ($key,$value) = each(%db)) { + while (my ($key,$value) = each(%$dbref)) { if ($value =~ s/^__FROZEN__//) { $value = thaw(&unescape($value)); } @@ -85,13 +88,7 @@ while (my $fname = shift) { } print "$key = ".(ref($value)?Dumper($value):$value)."\n"; } - untie %db; + &LONCAPA::locking_hash_untie($dbref); } exit; -###################################### -sub unescape { - my $str=shift; - $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - return $str; -}