Config::Vars

A module for keeping configuration variables in a central Perl file
Download

Config::Vars Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Eric J. Roode
  • Publisher web site:
  • http://search.cpan.org/~roode/

Config::Vars Tags


Config::Vars Description

A module for keeping configuration variables in a central Perl file Config::Vars is a Perl module for keeping configuration variables in a central Perl file.SYNOPSIS package My_Config_File; use Config::Vars; # Declare and initialize some variables in your config file. var $foo = 'some value'; var $arr = qw(some values); var %hash = (some => 'values'); # Declare an initialize some readonly variables. ro $foo2 = 'some value'; ro $arr2 = qw(some values); ro %hash2 = (some => 'values');Most sizeable projects require a number of configuration variables to be stored somewhere. Sometimes a config file is the best solution for this, but often a plain Perl module is used for this. The nice thing about using a Perl module is that you can do computations in the file, for example, initializing variables from previously-defined ones.The problem is that you have to do a bunch of repetitive accounting work to ensure the variables will be accessible from your main program and other modules. You should set up the module as an Exporter so that all the various components of your system will have access to the config variables in their own namespaces. You then need to put all of the config variable names into @EXPORT_OK. If you want your module to be strict-safe, you need to declare them all with our or use vars. Finally, you have to initialize the variable. It goes something like this: @EXPORT_OK = qw($president); use vars qw($president); $president = 'Grover Cleveland';Writing each variable name three times is a tedious waste of time. This module takes care of the repetitive coding tasks that you need to do in order to make your configuration module work.Config::Vars also takes care of importing the Exporter module and setting up @EXPORT_OK and @ISA. Requirements: · Perl


Config::Vars Related Software