DISQUS

In The Box: One config file to rule them all

  • paul · 2 years ago
    man, i read the entire thing thinking about webmin, probably because it was in the intro. didn't even put 2 and 2 together.
  • Christian · 2 years ago
    Hi,

    the perl should read:

    ###
    my $file = "apache.config";
    open(CONFIG, "< $file") or die "can't open $file: $!";
    my %config = map {
    s/#.*//; # Remove comments
    s/^\s+//; # Remove opening whitespace
    s/\s+$//; # Remove closing whitespace
    m/(.*?)\s*=\s*(.*)/; }
    ;

    # Print it out
    use Data::Dumper;
    print Dumper(\%config);
    ###

    ###
    my $file = "apache.config";
    open(CONFIG, "< $file") or die "can't open $file: $!";
    while () {
    chomp;
    s/#.*//; # Remove comments
    s/^\s+//; # Remove opening whitespace
    s/\s+$//; # Remove closing whitespace
    next unless length;
    my ($key, $value) = split(/\s*=\s*/, $_, 2);
    $config{$key} = $value;
    }

    # Print it out
    use Data::Dumper;
    print Dumper(\%config);
    ###


    Christian
  • SwellJoe · 1 year ago
    You're right, Christian. The editor in Wordpress is hateful and "corrects" certain characters, even when they're wrapped in pre tags.
  • HM2K · 1 year ago
    I had a similar issue to overcome, this is my solution, with slightly less overheads...

    http://www.hm2k.com/posts/storing-mysql-databas...

    It's mainly for use with PHP and Perl, but might work in other languages.
  • mrxinu · 1 year ago
    This was a great read. Thanks for writing it!