generate.pl 402 B

123456789101112131415161718192021222324252627282930
  1. use warnings;
  2. my %config;
  3. sub add_config {
  4. my ($prefix, $c) = @_;
  5. foreach my $key (keys $c) {
  6. my $val = $c->{$key};
  7. if (ref($val) eq 'HASH') {
  8. add_config($key . '.', $val);
  9. }
  10. unless (ref($val)) {
  11. $config{'@' . $prefix . $key . '@'} = $val;
  12. }
  13. }
  14. }
  15. add_config('', $CONFIG);
  16. my $regex = join '|', map {quotemeta} keys %config;
  17. for (<>) {
  18. s/($regex)/${config{$1}}/g;
  19. print;
  20. }