1. added export_user.pl to export user files (for interest and safety)
[spider.git] / perl / DXUser.pm
index 810bb7682d85c7f752249b013b2ef8ff3909fc81..c84598afad795680582b5fab55d9ccbff9a99567 100644 (file)
@@ -73,10 +73,15 @@ sub AUTOLOAD
 #
 sub init
 {
-       my ($pkg, $fn) = @_;
+       my ($pkg, $fn, $mode) = @_;
   
        confess "need a filename in User" if !$fn;
-       $dbm = tie (%u, MLDBM, $fn, O_CREAT|O_RDWR, 0666) or confess "can't open user file: $fn ($!)";
+       if ($mode) {
+               $dbm = tie (%u, MLDBM, $fn, O_CREAT|O_RDWR, 0666) or confess "can't open user file: $fn ($!)";
+       } else {
+               $dbm = tie (%u, MLDBM, $fn, O_RDONLY) or confess "can't open user file: $fn ($!)";
+       }
+       
        $filename = $fn;
 }