1 # Perl module for parsing Sherlock configuration files (using the config utility)
2 # (c) 2002 Martin Mares <mj@ucw.cz>
4 package Sherlock::Config;
15 push @options, "config|C=s" => sub { my ($o,$a)=@_; $defargs .= " -C'$a'"; };
16 push @options, "set|S=s" => sub { my ($o,$a)=@_; $defargs .= " -S'$a'"; };
17 Getopt::Long::GetOptions(@options) or return 0;
18 foreach my $section (keys %Sections) {
19 my $opts = $Sections{$section};
20 my $optlist = join(" ", keys %$opts);
21 my @l = `bin/config $defargs $section $optlist`;
24 $o =~ /^CF_([^=]+)="(.*)"\n$/ or die "Cannot parse bin/config output: $_";
27 if (ref $var eq "SCALAR") {
29 } elsif (ref $var eq "ARRAY") {
32 die ("Sherlock::Config::Parse: don't know how to set $o");