/[webpac2]/trunk/lib/WebPAC/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/lib/WebPAC/Lookup.pm

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

revision 15 by dpavlin, Sun Jul 17 10:42:23 2005 UTC revision 30 by dpavlin, Sun Jul 24 14:20:59 2005 UTC
# Line 3  package WebPAC::Lookup; Line 3  package WebPAC::Lookup;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
 use WebPAC::Common;  
   
6  use base qw/WebPAC::Common WebPAC::Normalize/;  use base qw/WebPAC::Common WebPAC::Normalize/;
7  use File::Slurp;  use File::Slurp;
8  use Data::Dumper;  use Data::Dumper;
# Line 42  value in lookup. Line 40  value in lookup.
40      'val' => 'v900' },      'val' => 'v900' },
41   ];   ];
42    
43    Just for a reference, lookup data is internally stored in
44    C<< $self->{'_lookup_data'} >>.
45    
46  =head1 FUNCTIONS  =head1 FUNCTIONS
47    
# Line 122  sub add($) { Line 122  sub add($) {
122                                  my $key = $self->fill_in($rec,$i->{'key'}) || next;                                  my $key = $self->fill_in($rec,$i->{'key'}) || next;
123                                  my @val = $self->fill_in($rec,$i->{'val'}) || next;                                  my @val = $self->fill_in($rec,$i->{'val'}) || next;
124                                  $log->debug("stored $key = ",sub { join(" | ",@val) });                                  $log->debug("stored $key = ",sub { join(" | ",@val) });
125                                  push @{$self->{'lookup'}->{$key}}, @val;                                  push @{$self->{'_lookup_data'}->{$key}}, @val;
126                          }                          }
127                  } else {                  } else {
128                          my $key = $self->fill_in($rec,$i->{'key'}) || next;                          my $key = $self->fill_in($rec,$i->{'key'}) || next;
129                          my @val = $self->fill_in($rec,$i->{'val'}) || next;                          my @val = $self->fill_in($rec,$i->{'val'}) || next;
130                          $log->debug("stored $key = ",sub { join(" | ",@val) });                          $log->debug("stored $key = ",sub { join(" | ",@val) });
131                          push @{$self->{'lookup'}->{$key}}, @val;                          push @{$self->{'_lookup_data'}->{$key}}, @val;
132                  }                  }
133          }          }
134    
# Line 161  sub lookup { Line 161  sub lookup {
161                  while (my $f = shift @in) {                  while (my $f = shift @in) {
162                          if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) {                          if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) {
163                                  my $k = $1;                                  my $k = $1;
164                                  if ($self->{'lookup'}->{$k}) {                                  if ($self->{'_lookup_data'}->{$k}) {
165                                          foreach my $nv (@{$self->{'lookup'}->{$k}}) {                                          foreach my $nv (@{$self->{'_lookup_data'}->{$k}}) {
166                                                  my $tmp2 = $f;                                                  my $tmp2 = $f;
167                                                  $tmp2 =~ s/lookup{$k}/$nv/g;                                                  $tmp2 =~ s/lookup{$k}/$nv/g;
168                                                  push @in, $tmp2;                                                  push @in, $tmp2;

Legend:
Removed from v.15  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26