gluon/scripts/configure.pl

41 lines
526 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 {
my ($prefix, $c) = @_;
foreach my $key (keys $c) {
my $val = $c->{$key};
if (ref($val)) {
add_config($key . '.', $val);
}
else {
$config{'@' . $prefix . $key . '@'} = $val;
}
}
}
sub read_config {
my $input = shift;
my $CONFIG = do $input;
add_config('', $CONFIG);
}
read_config 'site/site.pl';
my $regex = join '|', map {quotemeta} keys %config;
for (<>) {
s/($regex)/${config{$1}}/g;
print;
}