lookup_key and lookup_val types now support filters
[webpac] / all2xml.pl
index 976136e..7157de0 100755 (executable)
@@ -321,7 +321,7 @@ sub data2xml {
                                        } else {
                                                $display_data .= $ldel if ($display_data);
                                                my $tmp = mkformat($x,$display);
-                                               $display_data = $tmp if ($tmp);
+                                               $display_data .= $tmp if ($tmp);
                                        }
                                }
                                                
@@ -342,11 +342,21 @@ sub data2xml {
                                                if ($lookup_key) {
                                                        print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";
                                                } else {
-                                                       $lookup_key = $display;
+                                                       if ($filter) {
+                                                               no strict 'refs';
+                                                               $lookup_key = &$filter($display);
+                                                       } else {
+                                                               $lookup_key = $display;
+                                                       }
                                                }
                                        } elsif (lc($x->{type}) eq "lookup_val") {
                                                if ($lookup_key) {
-                                                       $lhash{$lookup_key} = $display;
+                                                       if ($filter) {
+                                                               no strict 'refs';
+                                                               $lhash{$lookup_key} = &$filter($display);
+                                                       } else {
+                                                               $lhash{$lookup_key} = $display;
+                                                       }
                                                } else {
                                                        print STDERR "WARNING: no lookup_key defined for  '$display'?";
                                                }
@@ -592,6 +602,8 @@ foreach my $database ($cfg->Sections) {
                #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;
                tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;
                print STDERR "creating lookup file '$lookup_file'\n";
+               # delete memory cache for lookup file
+               delete $cache->{lhash};
        }
 
        # open existing lookup file