[LON-CAPA-cvs] cvs: loncom /debugging_tools dump_db.pl

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 18 Mar 2005 19:44:38 -0000


matthew		Fri Mar 18 14:44:38 2005 EDT

  Modified files:              
    /loncom/debugging_tools	dump_db.pl 
  Log:
  -t now works in more places than it used to.
  Detects 'frozen' items and thaws them out, to be output by Dumper.
  
  
Index: loncom/debugging_tools/dump_db.pl
diff -u loncom/debugging_tools/dump_db.pl:1.3 loncom/debugging_tools/dump_db.pl:1.4
--- loncom/debugging_tools/dump_db.pl:1.3	Thu Sep  4 10:32:46 2003
+++ loncom/debugging_tools/dump_db.pl	Fri Mar 18 14:44:38 2005
@@ -4,7 +4,7 @@
 #
 # dump_db.pl - dump a GDBM database to standard output, unescaping if asked to.
 #
-# $Id: dump_db.pl,v 1.3 2003/09/04 14:32:46 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,6 +32,8 @@
 use strict;
 use Getopt::Long;
 use GDBM_File;
+use Data::Dumper;
+use Storable qw(freeze thaw);
 
 #
 # Options
@@ -71,16 +73,17 @@
         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) {
-            if ($value =~ /^\s*([0-9]{10,10})\s*$/) {
-                $value = $value.' [ '.localtime($1).' ]';
-            }
+        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;
 }