Config-Wild
view release on metacpan or search on metacpan
lib/Config/Wild.pm view on Meta::CPAN
=head3 set_attr
$cfg->set_attr( \%attr );
Set object attribute. See <L/METHODS/"new"> for a list of attributes.
=head2 Keyword-named Accessors Methods
You may access a value by specifying the keyword as the method,
instead of using the B<get()> method. The following are equivalent:
# keyword is foo
$foo = $cfg->get( 'foo' );
$foo = $cfg->foo;
If C<foo> doesn't exist, it returns C<undef>.
You can set a value using a similar syntax. The following are
equivalent, if the key already exists:
$cfg->set( 'key', $value );
$cfg->key( $value );
If the key doesn't exist, the second statement does nothing.
It is a bit more time consuming to use these methods rather than using
B<set> and B<get>.
=head1 LOGGING
B<Config::Wild> uses L<Log::Any> to log C<info> level messages during
searching and reading configuration files. In the event of an error
during searching, reading, and parsing files, it will log C<error>
level messages.
=head1 ERRORS AND EXCEPTIONS
For most errors, B<Config::Wild> will croak.
If an error occurs during searching for, reading, or parsing a
configuration file, objects in the following classes will be thrown:
=over
=item *
Config::Wild::Error::exists
=item *
Config::Wild::Error::read
=item *
Config::Wild::Error::parse
=back
They stringify into an appropriate error message.
=head1 BUGS AND LIMITATIONS
You can make new bug reports, and view existing ones, through the
web interface at L<https://rt.cpan.org/Public/Dist/Display.html?Name=Config-Wild>.
=head1 AUTHOR
Diab Jerius <djerius@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
=cut
__END__
#pod =head1 SYNOPSIS
#pod
#pod use Config::Wild;
#pod $cfg = Config::Wild->new();
#pod $cfg = Config::Wild->new( $configfile, \%attr );
#pod
#pod =head1 DESCRIPTION
#pod
#pod This module reads I<key - value> data pairs from a file. What sets
#pod it apart from other configuration systems is that keys may contain
#pod Perl regular expressions, allowing one entry to match multiple
#pod requested keys.
#pod
#pod Configuration information in the file has the form
#pod
#pod key = value
#pod
#pod where I<key> is a token which may contain Perl regular expressions
#pod surrounded by curly brackets, e.g.
#pod
#pod foobar.{\d+}.name = goo
#pod
#pod and I<value> is the remainder of the line after any whitespace following
#pod the C<=> character is removed.
#pod
#pod Keys which contain regular expressions are termed I<wildcard>
#pod keys; those without are called I<absolute> keys. Wildcard
#pod keys serve as templates to allow grouping of keys which have
#pod the same value. For instance, say you've got a set of keys which
#pod normally have the same value, but where on occasion you'd like to
#pod override the default:
#pod
#pod p.{\d+}.foo = goo
#pod p.99.foo = flabber
#pod
#pod I<value> may reference environment variables or other B<Config::Wild>
#pod variables via the following expressions:
#pod
#pod =over 4
#pod
( run in 0.620 second using v1.01-cache-2.11-cpan-39bf76dae61 )