Config::Context::ConfigGeneral - Use Config::General (Apache-style) config files with Config::Context
use Config::Context; my $config_text = ' <Location /users> title = "User Area" </Location> <LocationMatch \.*(jpg|gif|png)$> image_file = 1 </LocationMatch> '; my $conf = Config::Context->new( string => $config_text, driver => 'ConfigGeneral', match_sections => [ { name => 'Location', match_type => 'path', }, { name => 'LocationMatch', match_type => 'regex', }, ], ); my %config = $conf->context('/users/~mary/index.html'); use Data::Dumper; print Dumper(\%config); -------- $VAR1 = { 'title' => 'User Area', 'image_file' => undef, }; my %config = $conf->getall_matching('/users/~biff/images/flaming_logo.gif'); print Dumper(\%config); -------- $VAR1 = { 'title' => 'User Area', 'image_file' => 1, };
This module uses Config::General to parse Apache-style config files for Config::Context. See the Config::Context docs for more information.
Config::General
Config::Context
In addition to the options normally enabled by Config::Scoped, the following options are turned on by default:
-MergeDuplicateBlocks => 1 -MergeDuplicateOptions => 1 -IncludeRelative => 1
You can change this behaviour by passing a different value to driver_params to new:
driver_params
new
my $conf = Config::Context->new( driver => 'ConfigGeneral', driver_options => { ConfigGeneral = > { -MergeDuplicateBlocks => 0, }, }, );
my $driver = Config::Context::ConfigGeneral->new( file => $config_file, lower_case_names => 1, # optional options => { # ... } );
or:
my $driver = Config::Context::ConfigGeneral->new( string => $config_string, lower_case_names => 1, # optional options => { # ... } );
Returns a new driver object, using the provided options.
Returns the data structure for the parsed config.
Returns a list of all the config files read, including any config files included in the main file.
Returns the modules used to parse the config. In this case: Config::General
Instead of:
<Location '/foo'> </Location>
Use:
<Location /foo> </Location>
Config::Context CGI::Application::Plugin::Config::Context Config::General
Copyright 2004-2005 Michael Graham, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Config::Context, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Context
CPAN shell
perl -MCPAN -e shell install Config::Context
For more information on module installation, please visit the detailed CPAN module installation guide.