59 |
=cut |
=cut |
60 |
|
|
61 |
sub new { |
sub new { |
62 |
my $class = shift; |
my $class = shift; |
63 |
my $self = {@_}; |
my $self = {@_}; |
64 |
bless($self, $class); |
bless($self, $class); |
65 |
|
|
66 |
my $log = $self->_get_logger(); |
my $log = $self->_get_logger(); |
83 |
|
|
84 |
$log->logconfess("lookup config file isn't ARRAY but ", sub { Dumper( $self->{'lookup_def'} ) }) if ($self->{'lookup_def'} !~ /ARRAY/o); |
$log->logconfess("lookup config file isn't ARRAY but ", sub { Dumper( $self->{'lookup_def'} ) }) if ($self->{'lookup_def'} !~ /ARRAY/o); |
85 |
|
|
86 |
$self->{'is_lookup_regex'} ||= 'lookup{\[[^\{\}]+\]}'; |
$self->{'is_lookup_regex'} ||= 'lookup{[^\{\}]+}'; |
87 |
$self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}'; |
$self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}'; |
88 |
|
|
89 |
|
|
146 |
|
|
147 |
Perform lookups on format supplied to it. |
Perform lookups on format supplied to it. |
148 |
|
|
149 |
my $text = $lookup->lookup('[v900]'); |
my $text = $lookup->lookup('lookup{v900}'); |
150 |
|
|
151 |
Lookups can be nested (like C<[d:[a:[v900]]]>). |
Lookups can be nested (like lookup{B<d:>lookup{B<a:>lookup{B<v900>}}}). |
152 |
|
|
153 |
=cut |
=cut |
154 |
|
|
162 |
if ($tmp =~ $self->{'LOOKUP_REGEX'}) { |
if ($tmp =~ $self->{'LOOKUP_REGEX'}) { |
163 |
my @in = ( $tmp ); |
my @in = ( $tmp ); |
164 |
|
|
|
$log->debug("lookup for: ",$tmp); |
|
|
|
|
165 |
my @out; |
my @out; |
166 |
while (my $f = shift @in) { |
while (my $f = shift @in) { |
167 |
if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) { |
if ($f =~ $self->{'LOOKUP_REGEX_SAVE'}) { |
179 |
push @out, $f; |
push @out, $f; |
180 |
} |
} |
181 |
} |
} |
182 |
|
$log->debug("lookup for: ",$tmp, " returned: ", join(", ",@out)); |
183 |
|
|
184 |
$log->logconfess("return is array and it's not expected!") unless wantarray; |
$log->logconfess("return is array and it's not expected!") unless wantarray; |
185 |
|
|
186 |
return @out; |
return @out; |
187 |
} else { |
} else { |
188 |
return $tmp; |
return $tmp; |