2013-09-30 17:04:35 +00:00
|
|
|
use warnings;
|
|
|
|
|
|
|
|
|
|
|
|
my %config;
|
|
|
|
|
|
|
|
sub add_config {
|
|
|
|
my ($prefix, $c) = @_;
|
|
|
|
|
|
|
|
foreach my $key (keys $c) {
|
|
|
|
my $val = $c->{$key};
|
|
|
|
|
|
|
|
if (ref($val) eq 'HASH') {
|
|
|
|
add_config($key . '.', $val);
|
|
|
|
}
|
2014-01-21 01:55:02 +00:00
|
|
|
elsif (ref($val) eq 'ARRAY') {
|
2014-02-23 05:01:35 +00:00
|
|
|
$config{'@' . $prefix . $key . '@'} = join ' ', map {s/'/'\\''/g; "'" . $_ . "'"} @{$val}
|
2014-01-21 01:55:02 +00:00
|
|
|
}
|
2013-09-30 17:04:35 +00:00
|
|
|
unless (ref($val)) {
|
|
|
|
$config{'@' . $prefix . $key . '@'} = $val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_config('', $CONFIG);
|
|
|
|
|
|
|
|
|
|
|
|
my $regex = join '|', map {quotemeta} keys %config;
|
|
|
|
|
|
|
|
|
|
|
|
for (<>) {
|
|
|
|
s/($regex)/${config{$1}}/g;
|
|
|
|
print;
|
|
|
|
}
|