3 # Export the user file in a form that can be directly imported
4 # back with a do statement
9 # search local then perl directories
13 # root of directory tree for this system
15 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
17 unshift @INC, "$root/perl"; # this IS the right way round!
18 unshift @INC, "$root/local";
26 $userfn = $ARGV[0] if @ARGV;
28 croak "need a filename";
31 DXUser->init($userfn);
33 open OUT, ">$userfn.asc" or die;
36 $t = scalar localtime;
37 print OUT "#!/usr/bin/perl
39 # The exported userfile for a DXSpider System
50 @all = DXUser::get_all_calls();
53 my $ref = DXUser->get($a);
54 my $s = $ref->encode() if $ref;
55 print OUT "'$a' => q{$s},\n" if $a;
63 # there were $count records
74 use MLDBM qw(DB_File);
79 # initialise the system
83 my ($pkg, $fn, $mode) = @_;
85 confess "need a filename in User" if !$fn;
87 $dbm = tie (%u, MLDBM, $fn, O_CREAT|O_RDWR, 0666) or confess "can't open user file: $fn ($!)";
89 $dbm = tie (%u, MLDBM, $fn, O_RDONLY) or confess "can't open user file: $fn ($!)";
105 # get - get an existing user - this seems to return a different reference everytime it is
113 # $call =~ s/-\d+$//o; # strip ssid
118 # get all callsigns in the database
123 return (sort keys %u);
128 # create a string from a user reference
137 for $f (sort keys %$self) {
138 my $val = $$self{$f};
139 if (ref $val) { # it's an array (we think)
149 $out .= "'$f'=>'$val',";
152 $out .= " }, 'DXUser')";