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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jun 2006 14:37:40 -0000


albertel		Tue Jun 27 10:37:40 2006 EDT

  Modified files:              
    /loncom/debugging_tools	excise_from_db.pl 
  Log:
  - morphing to use LONCAPA.pm
  
  
Index: loncom/debugging_tools/excise_from_db.pl
diff -u loncom/debugging_tools/excise_from_db.pl:1.2 loncom/debugging_tools/excise_from_db.pl:1.3
--- loncom/debugging_tools/excise_from_db.pl:1.2	Fri Mar 18 19:39:54 2005
+++ loncom/debugging_tools/excise_from_db.pl	Tue Jun 27 10:37:40 2006
@@ -4,7 +4,7 @@
 #
 # excise_from_db.pl - Remove a key from a db file.
 #
-# $Id: excise_from_db.pl,v 1.2 2005/03/19 00:39:54 matthew Exp $
+# $Id: excise_from_db.pl,v 1.3 2006/06/27 14:37:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,6 +31,8 @@
 #################################################
 use strict;
 use GDBM_File;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
 
 #
 # Options
@@ -43,27 +45,15 @@
     exit;
 }
 
-my %db;
-if (! tie(%db,'GDBM_File',$fname,&GDBM_WRITER,0640)) {
+my $dbref =&LONCAPA::locking_hash_tie($fname,&GDBM_WRCREAT());
+if (! $dbref) {
     warn "Unable to tie to $fname";
     next;
 }
-delete($db{$key});
-delete($db{&escape($key)});
+delete($dbref->{$key});
+delete($dbref->{&escape($key)});
 
-untie %db;
+&LONCAPA::locking_hash_untie($dbref);
 
 exit;
 
-######################################
-sub escape {
-    my $str=shift;
-    $str =~ s/(\W)/"%".unpack('H2',$1)/eg;
-    return $str;
-}
-
-sub unescape {
-    my $str=shift;
-    $str =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
-    return $str;
-}