Config::Easy

Access to a simple key-value configuration file
Download

Config::Easy Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jon Bjornstad
  • Publisher web site:
  • http://search.cpan.org/~jonbj/

Config::Easy Tags


Config::Easy Description

Access to a simple key-value configuration file The statement: use Config::Easy "conf.txt";will take the file named "conf.txt" in the current directory as the default configuration file.Lines from the file have leading and trailing blanks trimmed. Comments begin with # and continue to the end of the line. Entirely blank lines are ignored.Lines are divided into key and value at the first white space on the line. These key-value pairs are inserted into the %C hash which is then exported into the current package. # personal information empname Harold ssn 123-45-6789 phone 876-555-1212 print "$C{empname} - $C{ssn}\n";The name is the minimal %C to visually emphasize the key name.The file 'conf.txt' can be overridden with a -F command line option. % prog -F newconf It can also be -Fnewconf, if you wish.To use a configuration file in the same folder as the Perl script itself you can use the core module FindBin: use FindBin; use Config::Easy "$FindBin::Bin/conf.txt";SYNOPSISTypical usage: conf.txt contains: ------- # vital information name Harriet city San Francisco # options verbose 1 # 0 or 1 ------- use Config::Easy 'conf.txt'; print "$C{name}\n" if $C{verbose};Or for an object oriented approach: use Config::Easy(); my $c = Config::Easy->new('conf.txt'); print $c->get('name'), "\n" if $c->get('verbose');For more details see the section OBJECT. Requirements: · Perl


Config::Easy Related Software