BW::Config.pm
use BW::Config; my $config = BW::Config->new( { filename => $filename } ); my $values = $config->values; my $config = BW::Config->new; $config->parse( { filename => $filename } ); my $values = $config->values; my $errstr; if(($errstr = $config->error)) { # report $errstr here }
BW::Config reads and parses simple configuration files.
Return the version string.
Set or return the filename used by BW::Config->parse.
Return an arrayref of keywords, in the order they appear in the config file.
Return a hashref of key/value pairs.
Return a hashref of key/arrayref pairs for multi-item values.
Return the latest error condition. The error string is cleared when it is read.
The config file format is very simple. It's a line-oriented format where keys and values are separated by an equals sign (=).
key = value
Whitespace surrounding the keys and values is ignored.
Array values (multiple values per key) are separated by colons.
key = value:value:value:value
If you want the raw colon-separated value, you can get that with the values method.
Lines that begin with '#' are ignored.
# this is a comment
anything after '#' to the end of the line is considered a comment and is ignored.
key = value # comment comment blah blah blah
All leading and trailing whitespace are trimed, and a key without a value is assumed to have a zero-length string as the value.
Values are never undef. A zero-length string is provided for null content.
Errors are reported via the BW::Config->error method. It's a good idea to check this before using the values from your config file.
if((my $errorstring = $config->error)) { die $errorstring; # or some other way of reporting the error }
There is no quoting mechanism for the config file. The colon-separated arrays are particularly weak. There should be a way to quote a colon so it's not interpreted as such.
There should also be a way to quote strings and quote marks. These may be features for a future version.
Written by Bill Weinman <http://bw.org/>.
Copyright (c) 1995-2010 The BearHeart Group, LLC
2010-02-14 bw 1.1 - initial CPAN version 2008-04-02 bw - initial BW-Lib version
To install BW::CGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BW::CGI
CPAN shell
perl -MCPAN -e shell install BW::CGI
For more information on module installation, please visit the detailed CPAN module installation guide.