added new DXUser with homemade data->ref and ref->data routines
[spider.git] / perl / export_user.pl
1 #!/usr/bin/perl
2 #
3 # Export the user file in a form that can be directly imported
4 # back with a do statement
5 #
6
7 require 5.004;
8
9 # search local then perl directories
10 BEGIN {
11         # root of directory tree for this system
12         $root = "/spider"; 
13         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
14         
15         unshift @INC, "$root/perl";     # this IS the right way round!
16         unshift @INC, "$root/local";
17 }
18
19 use DXVars;
20 use DXUser;
21
22 $userfn = $ARGV[0] if @ARGV;
23
24 DXUser->init($userfn);
25
26 @all = DXUser::get_all_calls();
27 $t = scalar localtime;
28 print "#!/usr/bin/perl
29 #
30 # The exported userfile for a DXSpider System
31
32 # Input file: $userfn
33 #       Time: $t
34 #
35
36 package DXUser;
37
38 %u = (
39 ";
40
41 for $a (@all) {
42         my $ref = DXUser->get($a);
43         my $s = $ref->encode();
44         
45         print "'$a' => qq{ $s },\n";
46         $count++;
47 }
48 print ");\n
49 #
50 # there were $count records
51 #\n";
52