-
-
09 Aug 2007 19:48:08 UTC
- Distribution: AppConfig-Exporter
- Module version: 1.5
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (474 / 17 / 1)
- Kwalitee
Bus factor: 0- 90.16% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (3.64KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Ben H Kram
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
AppConfig::Exporter - Allow modules to import AppConfig sections from a shared configuration.
SYNOPSIS
package MyConfig; use base qw( AppConfig::Exporter ); __PACKAGE__->configure( Config_File => 'myfile.conf', AppConfig_Options => { CASE => 0 }, AppConfig_Define => { Fun_Pickles => {ARGCOUNT => ARGCOUNT_LIST} } ); 1;
USAGE
AppConfig::Exporter is intended to be subclassed to specify your configuration file and any options. Then, you can request a hash of any section from the configuration file by specifying it as a symbol to be imported in the use statement:
# myfile.conf [fruit] oranges = 'tasty' apples = 'sweet' # some code elsewhere... use MyConfig qw(fruit); print "$fruit{oranges}!"; # tasty! my $appconfig = MyConfig->AppConfig;
CONFIGURATION
- configure
-
This is how your class is initialized. You must specify a Config_File, and you may specify a hashref of AppConfig_Options and AppConfig_Define.
- Config_File
-
Required - path to your AppConfig compatible config file
__PACKAGE__->configure( Config_File => 'myfile.conf' );
- AppConfig_Options
-
Hash ref that will be fed to AppConfig - you can override this module's defaults, which are:
CASE => 1, CREATE => 1, GLOBAL => { ARGCOUNT => ARGCOUNT_ONE, }
For example:
__PACKAGE__->configure( Config_File => 'myfile.conf', AppConfig_Options => { CASE => 0 } );
- AppConfig_Define
-
Hash ref that will be fed to AppConfig as a define statement if you wish for a specific variable to have different properties than the global ones.
Note: So that you can use AppConfig's constants, this module automatically imports AppConfig's b<:argcount> tag into your package for you.
__PACKAGE__->configure( Config_File => 'myfile.conf', AppConfig_Define => { Fun_Pickles => {ARGCOUNT => ARGCOUNT_LIST} } );
- import
-
This does the heavy lifting using the Exporter. You don\'t call this directly - use will do it for you.
- AppConfig
-
You can use this to access the the raw AppConfig object that the exporter sources for configuration.
AUTHOR
Ben H Kram,
<bkram at dce.harvard.edu>
ACKNOWLEDGEMENTS
Andy Wardley, for his excellent AppConfig module.
COPYRIGHT & LICENSE
Copyright 2007 Harvard University and Fellows, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install AppConfig::Exporter, copy and paste the appropriate command in to your terminal.
cpanm AppConfig::Exporter
perl -MCPAN -e shell install AppConfig::Exporter
For more information on module installation, please visit the detailed CPAN module installation guide.