use strict;
use warnings;
+use Carp (qw(cluck confess));
use Exporter;
-@LiCoM::Config::EXPORT_OK = ('get_config read_config');
+@LiCoM::Config::EXPORT_OK = (qw(get_config set_config read_config));
@LiCoM::Config::ISA = ('Exporter');
our $Config = {};
return (1);
-=head1 STATIC FUNCTIONS
+=head1 EXPORTED FUNCTIONS
=over 4
-=item LiCoM::Config-E<gt>B<get_config> (I<$key>)
+=item B<get_config> (I<$key>)
Returns the value for I<$key> or undef if it's unknown.
sub get_config
{
- my $pkg = shift;
my $key = shift;
+ cluck ("\$key was not defined") unless (defined ($key));
+
if (!%$Config)
{
read_config ();
return ($Config->{$key});
}
-=item LiCoM::Config-E<gt>B<set_config> (I<$key>, I<$value>)
+=item B<set_config> (I<$key>, I<$value>)
Sets the value of I<$key> to I<$value>.
sub set_config
{
- my $pkg = shift;
my $key = shift;
my $val = shift;
+ cluck ("\$key was not defined") unless (defined ($key));
+
$Config->{$key} = $val;
}
-=item LiCoM::Config-E<gt>B<read_config> ([I<@files>])
+=item B<read_config> ([I<@files>])
Read the config from the files given or F</etc/licom/licom.conf> and
F<~/.licomrc> if no files were given.
my $file = $_;
next unless (-r $file);
- read_file ($file, $config);
+ read_file ($file, $Config);
}
- return ($config);
+ return ($Config);
}
sub read_file