/[webpac]/branches/humanistika/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 /branches/humanistika/filter/mem_lookup.pm

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

trunk/filter/mem_lookup.pm revision 207 by dpavlin, Sat Jan 31 21:03:06 2004 UTC branches/humanistika/filter/mem_lookup.pm revision 748 by dpavlin, Tue Jun 6 12:35:31 2006 UTC
# Line 23  Line 23 
23  #   indexer, so it's save to leave type="" undefiend  #   indexer, so it's save to leave type="" undefiend
24  # - lookup will (of course) return one or more values  # - lookup will (of course) return one or more values
25    
26    use warnings;
27    use strict;
28    
29  sub mem_lookup {  sub mem_lookup {
30          my @out;          my @out;
31          foreach (@_) {          foreach (@_) {
32                  if (/^(.+)\s=>\s(.+)$/) {                  if (/^(.+)\s=>\s(.+)$/) {
33                          my ($k,$v) = ($1,$2);                          my ($k,$v) = ($1,$2);
34                          # store in array if it doesn't exist                          # store in array if it doesn't exist
35                          if (! grep(/^$v$/, @{$main::cache->{mem_lookup}->{$k}})) {                          if (! grep(/^\Q$v\E$/, @{$main::cache->{mem_lookup}->{$k}})) {
36                                  push @{$main::cache->{mem_lookup}->{$k}}, $v;                                  push @{$main::cache->{mem_lookup}->{$k}}, $v;
37  #print STDERR "## mem_lookup store: $k => $v [",join("|",@{$main::cache->{mem_lookup}->{$k}}),"]\n";  #print STDERR "## mem_lookup store: $k => $v [",join("|",@{$main::cache->{mem_lookup}->{$k}}),"]\n";
38                          }                          }
# Line 58  sub mem_lookup { Line 61  sub mem_lookup {
61                          my ($pre,$k,$post) = ($1,$2,$3);                          my ($pre,$k,$post) = ($1,$2,$3);
62                          if ($main::cache->{mem_lookup}->{$k}) {                          if ($main::cache->{mem_lookup}->{$k}) {
63  #print STDERR "## mem_lookup fetch $k == ".join("|",@{$main::cache->{mem_lookup}->{$k}})."\n";  #print STDERR "## mem_lookup fetch $k == ".join("|",@{$main::cache->{mem_lookup}->{$k}})."\n";
64                                  foreach my $v (@{$main::cache->{mem_lookup}->{$k2}}) {                                  foreach my $v (@{$main::cache->{mem_lookup}->{$k}}) {
65                                          push @out,$pre.$v.$post;                                          push @out,$pre.$v.$post;
66                                  }                                  }
67                          }                          }
# Line 71  sub mem_lookup { Line 74  sub mem_lookup {
74          }          }
75  #print STDERR "mem_lookup dump: ",Dumper($main::cache->{mem_lookup}),"\n";  #print STDERR "mem_lookup dump: ",Dumper($main::cache->{mem_lookup}),"\n";
76  #print STDERR "out: ".Dumper(@out)."\n" if (@out);  #print STDERR "out: ".Dumper(@out)."\n" if (@out);
77          return @out;          return wantarray ? @out : shift @out;
78  }  }
79    
80  1;  1;

Legend:
Removed from v.207  
changed lines
  Added in v.748

  ViewVC Help
Powered by ViewVC 1.1.26