5 use Carp (qw(cluck confess));
9 @LiCoM::Config::EXPORT_OK = (qw(get_config set_config read_config));
10 @LiCoM::Config::ISA = ('Exporter');
16 =head1 EXPORTED FUNCTIONS
20 =item B<get_config> (I<$key>)
22 Returns the value for I<$key> or undef if it's unknown.
30 cluck ("\$key was not defined") unless (defined ($key));
37 return ($Config->{$key});
40 =item B<set_config> (I<$key>, I<$value>)
42 Sets the value of I<$key> to I<$value>.
51 cluck ("\$key was not defined") unless (defined ($key));
53 $Config->{$key} = $val;
56 =item B<read_config> ([I<@files>])
58 Read the config from the files given or F</etc/licom/licom.conf> and
59 F<~/.licomrc> if no files were given.
65 my @files = ('/etc/licom/licom.conf');
71 elsif (defined ($ENV{'HOME'}) and (-d $ENV{'HOME'}))
73 push (@files, $ENV{'HOME'} . '/.licomrc');
79 next unless (-r $file);
81 read_file ($file, $Config);
89 my $file = @_ ? shift : '/etc/licom/licom.conf';
90 my $config = @_ ? shift : {};
93 open ($fh, "< $file") or die ("open ($file): $!");
99 if ($line =~ m/^(\w+):\s*"(.+)"\s*$/)
104 $config->{$key} = $val;
117 Florian octo Forster E<lt>octo at verplant.orgE<gt>