MOSES-MOBY
view release on metacpan or search on metacpan
lib/MOSES/MOBY/Config.pm view on Meta::CPAN
return keys %Config unless @_;
# if called with a single argument, return the value
# matching this key
return $Config{$_[0]} if @_ == 1;
# more arguments means adding...
# return $Config{$_[0]} = $_[1];
my $ret = $Config{$_[0]} = $_[1];
MOSES::MOBY::Config->import_names ('MOBYCFG');
return $ret;
}
# remove one, more, or all configuration arguments
=head2 delete
removes one or more of the configuration keys and their associated values.
=cut
sub delete {
shift;
# if called with no arguments, delete all keys
%Config = () and return unless @_;
# if called with arguments, delete the matching keys
foreach my $key (@_) {
delete $Config{$key};
}
}
# return a stringified version of all configuration options; an
# optional argument is a name for variable into which it is
# stringified (I do not know how to express it better: simply speaking
# this argument is passed to the Data::Dumper->Dump as the variable
# name)
=head2 dump
Returns a stringified version of all configuration parameters;
If passed a scalar parameter, then the dump will be given that variable name.
This dump can be eval{}'ed.
=cut
sub dump {
shift;
my $varname = @_ ? shift : 'CONFIG';
require Data::Dumper;
return Data::Dumper->Dump ( [\%Config], [$varname]);
}
# imports names into the caller's namespace as global variables;
# adapted from the same method in Config::Simple
sub import_names {
shift;
my $namespace = @_ ? shift : (caller)[0];
return if $namespace eq 'MOSES::MOBY::Config';
no strict 'refs';
no warnings; # avoid "Useless use of a variable..."
while ( my ($key, $value) = each %Config ) {
$key =~ s/\W/_/g;
${$namespace . '::' . uc($key)} = $value;
}
}
# return a list of configuration files successfully read (so far)
=head2 ok_files
returns a list of the configuration files successfully read thus far ...
=cut
sub ok_files {
return sort keys %Success;
}
# return a hash of configuration files un-successfully read (so far) -
# with corresponding error messages
=head2 failed_files
returns a hash of the configuration files unsuccessfully read thus far and their corresponding error messages.
=cut
sub failed_files {
return %Unsuccess;
}
1;
__END__
( run in 1.830 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )