5 |
|
|
6 |
use base qw/WebPAC::Common WebPAC::Normalize/; |
use base qw/WebPAC::Common WebPAC::Normalize/; |
7 |
use File::Slurp; |
use File::Slurp; |
8 |
|
use YAML qw/LoadFile/; |
9 |
use Data::Dumper; |
use Data::Dumper; |
10 |
|
|
11 |
=head1 NAME |
=head1 NAME |
14 |
|
|
15 |
=head1 VERSION |
=head1 VERSION |
16 |
|
|
17 |
Version 0.01 |
Version 0.02 |
18 |
|
|
19 |
=cut |
=cut |
20 |
|
|
21 |
our $VERSION = '0.01'; |
our $VERSION = '0.02'; |
22 |
|
|
23 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
24 |
|
|
69 |
|
|
70 |
my $lookup_code = read_file($lookup_file) || $log->logconfess("can't read lookup file $lookup_file: $!"); |
my $lookup_code = read_file($lookup_file) || $log->logconfess("can't read lookup file $lookup_file: $!"); |
71 |
|
|
72 |
{ |
if ($lookup_file =~ m#\.pm$#) { |
73 |
no strict 'vars'; |
no strict 'vars'; |
74 |
do $lookup_file or $log->logdie("Failed to read configuration parameters '$lookup_file' $! $@"); |
do $lookup_file or $log->logdie("Failed to read configuration parameters '$lookup_file' $! $@"); |
75 |
$self->{'lookup_def'} = \@lookup || $log->logdie("lookup config $lookup_file doesn't produce \@lookup array"); |
$self->{'lookup_def'} = \@lookup || $log->logdie("lookup config $lookup_file doesn't produce \@lookup array"); |
76 |
|
} elsif ($lookup_file =~ m#\.(:?yml|yaml)$#) { |
77 |
|
my $yaml = LoadFile( $lookup_file ) || $log->logdie("lookup YAML file $lookup_file error: $!"); |
78 |
|
$self->{'lookup_def'} = $yaml->{lookup} || $log->logdie("lookup YAML file $lookup_file should begin with 'lookup:'"); |
79 |
|
} else { |
80 |
|
$log->logide("unsupported lookup file $lookup_file"); |
81 |
} |
} |
82 |
|
|
83 |
$log->logconfess("lookup config file isn't ARRAY", 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); |
84 |
|
|
85 |
$self->{'is_lookup_regex'} ||= 'lookup{[^\{\}]+}'; |
$self->{'is_lookup_regex'} ||= 'lookup{[^\{\}]+}'; |
86 |
$self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}'; |
$self->{'save_lookup_regex'} ||= 'lookup{([^\{\}]+)}'; |