gluon/scripts/configure.pl

41 lines
529 B
Perl
Raw Normal View History

2013-09-28 16:39:32 +00:00
#!/usr/bin/perl
use warnings;
use strict;
my %config;
sub add_config {
2013-09-30 15:14:40 +00:00
my ($prefix, $c) = @_;
2013-09-28 16:39:32 +00:00
2013-09-30 15:14:40 +00:00
foreach my $key (keys $c) {
my $val = $c->{$key};
2013-09-28 16:39:32 +00:00
2013-09-30 15:14:40 +00:00
if (ref($val) eq 'HASH') {
add_config($key . '.', $val);
}
unless (ref($val)) {
$config{'@' . $prefix . $key . '@'} = $val;
}
2013-09-28 16:39:32 +00:00
}
}
sub read_config {
2013-09-30 15:14:40 +00:00
my $input = shift;
my $CONFIG = do $input;
add_config('', $CONFIG);
2013-09-28 16:39:32 +00:00
}
2013-09-29 12:44:17 +00:00
read_config 'site/site.conf';
2013-09-28 16:39:32 +00:00
my $regex = join '|', map {quotemeta} keys %config;
for (<>) {
2013-09-30 15:14:40 +00:00
s/($regex)/${config{$1}}/g;
print;
2013-09-28 16:39:32 +00:00
}