/[webpac]/trunk/filter/mem_lookup.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/filter/mem_lookup.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 205 by dpavlin, Sun Jan 18 21:11:39 2004 UTC revision 351 by dpavlin, Tue Jun 15 22:14:41 2004 UTC
# Line 31  sub mem_lookup { Line 31  sub mem_lookup {
31                          # store in array if it doesn't exist                          # store in array if it doesn't exist
32                          if (! grep(/^$v$/, @{$main::cache->{mem_lookup}->{$k}})) {                          if (! grep(/^$v$/, @{$main::cache->{mem_lookup}->{$k}})) {
33                                  push @{$main::cache->{mem_lookup}->{$k}}, $v;                                  push @{$main::cache->{mem_lookup}->{$k}}, $v;
34  #print STDERR "## mem_lookup store: $k => $v\n";  #print STDERR "## mem_lookup store: $k => $v [",join("|",@{$main::cache->{mem_lookup}->{$k}}),"]\n";
35                          }                          }
36                  } elsif (/^(.*)\[([^\[]*)\[([^\[\]]+)\]([^\]]*)\](.*)$/) {                  } elsif (/\[[^\[\]]+\]/) {
37                          # indirect lookup [prefix[key]suffix]                          # lookup [key] recursivly
38                          my ($pre,$prek,$k,$postk,$post) = ($1,$2,$3,$4,$5);                          my @in = ( $_ );
39                          if ($main::cache->{mem_lookup}->{$k}) {  #print STDERR "mem_lookup: $_\n";
40                                  my @keys = @{$main::cache->{mem_lookup}->{$k}};                          while (my $f = shift @in) {
41  #print STDERR "## mem_lookup fetch keys $k == ".join("|",@keys)."\n";                                  if ($f =~ /\[([^\[\]]+)\]/) {
42                                  foreach my $k2 (@keys) {                                          my $k = $1;
43                                          if ($main::cache->{mem_lookup}->{$prek.$k2.$postk}) {                                          if ($main::cache->{mem_lookup}->{$k}) {
44                                                  foreach my $v (@{$main::cache->{mem_lookup}->{$prek.$k2.$postk}}) {  #print STDERR "mem_lookup key: $k = ";
45                                                          push @out,$pre.$v.$post;                                                  foreach my $nv (@{$main::cache->{mem_lookup}->{$k}}) {
46    #print STDERR "\t$nv\n";
47                                                            my $tmp = $f;
48                                                            $tmp =~ s/\[$k\]/$nv/g;
49                                                            push @in, $tmp;
50                                                  }                                                  }
51                                            } else {
52                                                    undef $f;
53                                          }                                          }
54                                  }                                  } elsif ($f) {
55  #print STDERR "## mem_lookup return values $k == ".join("|",@out)."\n";                                          push @out, $f;
56                                    }      
                         }  
                 } elsif (/^(.*)\[([^\[\]]+)\](.*)$/) {  
                         # direct lookup [key]  
                         my ($pre,$k,$post) = ($1,$2,$3);  
                         if ($main::cache->{mem_lookup}->{$k}) {  
 #print STDERR "## mem_lookup fetch $k == ".join("|",@{$main::cache->{mem_lookup}->{$k}})."\n";  
                                 foreach my $v (@{$main::cache->{mem_lookup}->{$k2}}) {  
                                         push @out,$pre.$v.$post;  
                                 }  
57                          }                          }
 #print STDERR "## mem_lookup return values $k == ".join("|",@out)."\n";  
   
58                  } else {                  } else {
59                          # value is undef                          # value is undef
60                          #warn "mem_lookup: invalid filter specification: '$_'";                          #warn "mem_lookup: invalid filter specification: '$_'";
61                  }                  }
62          }          }
63  #print STDERR "mem_lookup dump: ",Dumper($main::cache->{mem_lookup}),"\n";  #print STDERR "mem_lookup dump: ",Dumper($main::cache->{mem_lookup}),"\n";
64    #print STDERR "out: ".Dumper(@out)."\n" if (@out);
65          return @out;          return @out;
66  }  }
67    

Legend:
Removed from v.205  
changed lines
  Added in v.351

  ViewVC Help
Powered by ViewVC 1.1.26