@@ -1,3 +1,22 @@
+Revision history for Perl module AppConfig
+
+1.67 2015-01-18 NEILB
+ - Version bumped for a non-developer release, now I've sorted all
+ the pod issues.
+ - Added github repo to metadata and pod
+
+1.66_03 2015-01-16 NEILB
+ - More pod & whitespace cleanup
+
+1.66_02 2015-01-15 NEILB
+ - Getting pod fails from CPAN Testers for various recent versions
+ of Perl. There was an empty =item.
+
+1.66_01 2015-01-10 NEILB
+ - First dev release, to check that everything's ok.
+ - ABW granted co-maint, so I could set up a github repo and do a
+ release with it linked. Thanks to ABW, ADAMK, and MST.
+
#========================================================================
# Version 1.66 Date: 2007/07/06 (Andy Wardley)
#========================================================================
@@ -27,3 +27,4 @@ t/state.t
t/sys.t
TODO
META.yml Module meta-data (added by MakeMaker)
+META.json Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,48 @@
+{
+ "abstract" : "AppConfig is a bundle of Perl5 modules for reading configuration files and parsing command line arguments.",
+ "author" : [
+ "Andy Wardley <abw@wardley.org>"
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "ExtUtils::MakeMaker version 7.02, CPAN::Meta::Converter version 2.143240",
+ "license" : [
+ "unknown"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "AppConfig",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "inc"
+ ]
+ },
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Test::More" : "0"
+ }
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/neilbowers/AppConfig.git",
+ "web" : "https://github.com/neilbowers/AppConfig"
+ }
+ },
+ "version" : "1.67"
+}
@@ -1,14 +1,24 @@
---- #YAML:1.0
-name: AppConfig
-version: 1.66
-abstract: AppConfig is a bundle of Perl5 modules for reading configuration files and parsing command line arguments.
-license: ~
-generated_by: ExtUtils::MakeMaker version 6.31
-distribution_type: module
-requires:
- Test::More: 0
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
+---
+abstract: 'AppConfig is a bundle of Perl5 modules for reading configuration files and parsing command line arguments.'
author:
- - Andy Wardley <abw@wardley.org>
+ - 'Andy Wardley <abw@wardley.org>'
+build_requires:
+ ExtUtils::MakeMaker: '0'
+configure_requires:
+ ExtUtils::MakeMaker: '0'
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 7.02, CPAN::Meta::Converter version 2.143240'
+license: unknown
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: '1.4'
+name: AppConfig
+no_index:
+ directory:
+ - t
+ - inc
+requires:
+ Test::More: '0'
+resources:
+ repository: git://github.com/neilbowers/AppConfig.git
+version: '1.67'
@@ -1,5 +1,11 @@
use ExtUtils::MakeMaker;
+my $mm_ver = $ExtUtils::MakeMaker::VERSION;
+if ($mm_ver =~ /_/) { # dev version
+ $mm_ver = eval $mm_ver;
+ die $@ if $@;
+}
+
my %config = (
'NAME' => 'AppConfig',
'VERSION_FROM' => 'lib/AppConfig.pm', # finds $VERSION
@@ -21,6 +27,21 @@ my %config = (
'SUFFIX' => 'gz',
'PREOP' => 'pod2text lib/AppConfig.pm > README',
},
+
+ ($mm_ver <= 6.45
+ ? ()
+ : (META_MERGE => {
+ 'meta-spec' => { version => 2 },
+ resources => {
+ repository => {
+ type => 'git',
+ web => 'https://github.com/neilbowers/AppConfig',
+ url => 'git://github.com/neilbowers/AppConfig.git',
+ },
+ },
+ })
+ ),
+
);
## for PPD on win32
@@ -4,37 +4,37 @@ NAME
SYNOPSIS
use AppConfig;
-
+
# create a new AppConfig object
my $config = AppConfig->new( \%cfg );
-
+
# define a new variable
$config->define( $varname => \%varopts );
-
+
# create/define combined
my $config = AppConfig->new( \%cfg,
$varname => \%varopts,
$varname => \%varopts,
...
);
-
+
# set/get the value
$config->set( $varname, $value );
$config->get($varname);
-
+
# shortcut form
$config->varname($value);
$config->varname;
-
+
# read configuration file
$config->file($file);
-
+
# parse command line options
$config->args(\@args); # default to \@ARGV
-
+
# advanced command line options with Getopt::Long
$config->getopt(\@args); # default to \@ARGV
-
+
# parse CGI parameters (GET method)
$config->cgi($query); # default to $ENV{ QUERY_STRING }
@@ -53,14 +53,14 @@ OVERVIEW
verbose
nohelp
debug = On
-
+
# single value
home = /home/abw/
-
+
# multiple list value
file = /tmp/file1
file = /tmp/file2
-
+
# multiple hash value
book camel = Programming Perl
book llama = Learning Perl
@@ -88,7 +88,7 @@ OVERVIEW
src = ~/websrc/docs/$site
lib = ~/websrc/lib
dest = ~/public_html/$site
-
+
[page]
header = $lib/header
footer = $lib/footer
@@ -100,7 +100,7 @@ OVERVIEW
line 1
line 2
FOOBAR
-
+
paths exe = "${PATH}:${HOME}/.bin"
paths link = <<'FOO'
${LD_LIBARRAY_PATH}:${HOME}/lib
@@ -133,9 +133,9 @@ OBTAINING AND INSTALLING THE AppConfig MODULE BUNDLE
CPAN stands for the Comprehensive Perl Archive Network.
This is a globally replicated collection of all known Perl
materials, including hundreds of unbundled modules.
-
+
[...]
-
+
For an up-to-date listing of CPAN sites, see
http://www.perl.com/perl/ or ftp://ftp.perl.com/perl/ .
@@ -260,7 +260,7 @@ DESCRIPTION
# create AppConfig
my $config = AppConfig->new('foo', 'bar');
-
+
# methods get passed through to internal AppConfig::State
$config->foo(100);
$config->set('bar', 200);
@@ -296,19 +296,19 @@ DESCRIPTION
ARGCOUNT => ARGCOUNT_ONE,
}
} );
-
+
$config->define("foo");
$config->define("bar", { ARGCOUNT => ARGCOUNT_NONE } );
is equivalent to:
my $config = AppConfig->new();
-
+
$config->define( "foo", {
DEFAULT => "<undef>",
ARGCOUNT => ARGCOUNT_ONE,
} );
-
+
$config->define( "bar",
DEFAULT => "<undef>",
ARGCOUNT => ARGCOUNT_NONE,
@@ -352,7 +352,7 @@ DESCRIPTION
EXPAND_VAR - expand C<$var> or C<$(var)> as other variables
EXPAND_UID - expand C<~> and C<~uid> as user's home directory
EXPAND_ENV - expand C<${var}> as environment variable
- EXPAND_ALL - do all expansions.
+ EXPAND_ALL - do all expansions.
VALIDATE
Regex which the intended variable value should match or code
@@ -388,30 +388,30 @@ DESCRIPTION
equivalent full specifications:
$config->define("foo|bar|baz!");
-
+
$config->define(
"foo" => {
ALIAS => "bar|baz",
ARGCOUNT => ARGCOUNT_NONE,
});
-
+
$config->define("name=s");
-
+
$config->define(
"name" => {
ARGCOUNT => ARGCOUNT_ONE,
});
-
+
$config->define("file|filelist|f=s@");
-
+
$config->define(
"file" => {
ALIAS => "filelist|f",
ARGCOUNT => ARGCOUNT_LIST,
});
-
+
$config->define("user|u=s%");
-
+
$config->define(
"user" => {
ALIAS => "u",
@@ -438,7 +438,7 @@ DESCRIPTION
is equivalent to
- $config->verbose(1);
+ $config->verbose(1);
Note that AppConfig defines the following methods:
@@ -595,10 +595,10 @@ DESCRIPTION
bin = ~/bin # expand '~' to home dir if EXPAND_UID
tmp = ~abw/tmp # as above, but home dir for user 'abw'
-
+
perl = $bin/perl # expand value of 'bin' variable if EXPAND_VAR
ripl = $(bin)/ripl # as above with explicit parens
-
+
home = ${HOME} # expand HOME environment var if EXPAND_ENV
See AppConfig::State for more information on expanding variable values.
@@ -612,7 +612,7 @@ DESCRIPTION
[block1]
foo = 10 # block1_foo = 10
-
+
[block2]
foo = 20 # block2_foo = 20
@@ -668,13 +668,13 @@ DESCRIPTION
myprog -file /tmp/foo -file /tmp/bar # $config->file('/tmp/foo')
# $config->file('/tmp/bar')
-
+
# file => [ '/tmp/foo', '/tmp/bar' ]
-
+
myprog -door "jim=Jim Morrison" -door "ray=Ray Manzarek"
# $config->door("jim=Jim Morrison");
# $config->door("ray=Ray Manzarek");
-
+
# door => { 'jim' => 'Jim Morrison', 'ray' => 'Ray Manzarek' }
See AppConfig::Args for further details on parsing command line
@@ -705,7 +705,7 @@ DESCRIPTION
ARGS => "=i",
ALIAS => "bar|baz",
});
-
+
# Getopt::Long specification: "foo|bar|baz=i"
Errors and warning generated by the Getopt::Long module are trapped and
@@ -738,7 +738,7 @@ DESCRIPTION
to restore the parameters to their intended values.
http://where.com/mycgi?title=%22The+Wrong+Trousers%22
-
+
# $config->title('"The Wrong Trousers"');
Please be considerate of the security implications of providing
@@ -793,6 +793,9 @@ CONSTANT DEFINITIONS
See AppConfig::State for full details of the use of these constants.
+REPOSITORY
+ <https://github.com/neilbowers/AppConfig>
+
AUTHOR
Andy Wardley, <abw@wardley.org>
@@ -15,7 +15,7 @@ package AppConfig::Args;
use strict;
use warnings;
use AppConfig::State;
-our $VERSION = '1.65';
+our $VERSION = '1.67';
#------------------------------------------------------------------------
@@ -33,7 +33,7 @@ our $VERSION = '1.65';
sub new {
my $class = shift;
my $state = shift;
-
+
my $self = {
STATE => $state, # AppConfig::State ref
@@ -42,7 +42,7 @@ sub new {
};
bless $self, $class;
-
+
# call parse() to parse any arg list passed
$self->parse(shift)
if @_;
@@ -166,12 +166,12 @@ in your Perl script:
AppConfig::Args is used automatically if you use the AppConfig module
and create an AppConfig::Args object through the parse() method.
-
+
AppConfig::File is implemented using object-oriented methods. A new
AppConfig::Args object is created and initialised using the new() method.
This returns a reference to a new AppConfig::File object. A reference to
an AppConfig::State object should be passed in as the first parameter:
-
+
my $state = AppConfig::State->new();
my $cfgargs = AppConfig::Args->new($state);
@@ -16,7 +16,7 @@ package AppConfig::CGI;
use strict;
use warnings;
use AppConfig::State;
-our $VERSION = '1.65';
+our $VERSION = '1.67';
#------------------------------------------------------------------------
@@ -40,7 +40,7 @@ sub new {
PEDANTIC => $state->_pedantic, # and pedantic flags
};
bless $self, $class;
-
+
# call parse(@_) to parse any arg list passed
$self->parse(@_)
if @_;
@@ -66,7 +66,7 @@ sub parse {
my $query = shift;
my $warnings = 0;
my ($variable, $value, $nargs);
-
+
# take a local copy of the state to avoid much hash dereferencing
my ($state, $debug, $pedantic) = @$self{ qw( STATE DEBUG PEDANTIC ) };
@@ -17,7 +17,7 @@ use strict;
use warnings;
use AppConfig;
use AppConfig::State;
-our $VERSION = '1.65';
+our $VERSION = '1.67';
#------------------------------------------------------------------------
@@ -257,7 +257,7 @@ sub parse {
print STDERR "$variable => $value (no expansion)\n"
if $debug;
}
-
+
# set the variable, noting any failure from set()
unless ($state->set($variable, $value)) {
$warnings++;
@@ -273,7 +273,7 @@ sub parse {
# restore original error handler
$state->_ehandler($errhandler);
-
+
# return $warnings => 0, $success => 1
return $warnings ? 0 : 1;
}
@@ -524,7 +524,7 @@ AppConfig::File object is created and initialised using the
AppConfig::File->new() method. This returns a reference to a new
AppConfig::File object. A reference to an AppConfig::State object
should be passed in as the first parameter:
-
+
my $state = AppConfig::State->new();
my $cfgfile = AppConfig::File->new($state);
@@ -649,7 +649,7 @@ style.
# comments are treated as a normal text.
The same applies to line continuation. \
_bar_
-
+
Note that you cannot use HERE document as a key in a hash or a name
of a variable.
@@ -669,10 +669,10 @@ Three different expansion types may be applied:
bin = ~/bin # expand '~' to home dir if EXPAND_UID
tmp = ~abw/tmp # as above, but home dir for user 'abw'
-
+
perl = $bin/perl # expand value of 'bin' variable if EXPAND_VAR
ripl = $(bin)/ripl # as above with explicit parens
-
+
home = ${HOME} # expand HOME environment var if EXPAND_ENV
See L<AppConfig::State> for more information on expanding variable values.
@@ -22,7 +22,7 @@ use strict;
use warnings;
use AppConfig::State;
use Getopt::Long 2.17;
-our $VERSION = '1.65';
+our $VERSION = '1.67';
#------------------------------------------------------------------------
@@ -45,7 +45,7 @@ sub new {
};
bless $self, $class;
-
+
# call parse() to parse any arg list passed
$self->parse(@_)
if @_;
@@ -67,7 +67,7 @@ sub parse {
my $self = shift;
my $state = $self->{ STATE };
my (@config, $args, $getopt);
-
+
local $" = ', ';
# we trap $SIG{__WARN__} errors and patch them into AppConfig::State
@@ -79,7 +79,7 @@ sub parse {
chomp($msg);
$state->_error("%s", $msg);
};
-
+
# slurp all config items into @config
push(@config, shift) while defined $_[0] && ! ref($_[0]);
@@ -206,12 +206,12 @@ in your Perl script:
AppConfig::Getopt is used automatically if you use the AppConfig module
and create an AppConfig::Getopt object through the getopt() method.
-
+
AppConfig::Getopt is implemented using object-oriented methods. A new
AppConfig::Getopt object is created and initialised using the new() method.
This returns a reference to a new AppConfig::Getopt object. A reference to
an AppConfig::State object should be passed in as the first parameter:
-
+
my $state = AppConfig::State->new();
my $getopt = AppConfig::Getopt->new($state);
@@ -40,7 +40,7 @@ package AppConfig::State;
use strict;
use warnings;
-our $VERSION = '1.65';
+our $VERSION = '1.67';
our $DEBUG = 0;
our $AUTOLOAD;
@@ -74,7 +74,7 @@ my @GLOBAL_OK = qw( DEFAULT EXPAND VALIDATE ACTION ARGS ARGCOUNT );
sub new {
my $class = shift;
-
+
my $self = {
# internal hash arrays to store variable specification information
VARIABLE => { }, # variable values
@@ -87,7 +87,7 @@ sub new {
VALIDATE => { }, # validation regexen or functions
ACTION => { }, # callback functions for when variable is set
GLOBAL => { }, # default global settings for new variables
-
+
# other internal data
CREATE => 0, # auto-create variables when set
CASE => 0, # case sensitivity flag (1 = sensitive)
@@ -97,7 +97,7 @@ sub new {
};
bless $self, $class;
-
+
# configure if first param is a config hash ref
$self->_configure(shift)
if ref($_[0]) eq 'HASH';
@@ -172,64 +172,64 @@ sub define {
# examine each variable configuration parameter
while (($opt, $val) = each %$cfg) {
$opt = uc $opt;
-
+
# DEFAULT, VALIDATE, EXPAND, ARGS and ARGCOUNT are stored as
# they are;
$opt =~ /^DEFAULT|VALIDATE|EXPAND|ARGS|ARGCOUNT$/ && do {
$self->{ $opt }->{ $var } = $val;
next;
};
-
+
# CMDARG has been deprecated
$opt eq 'CMDARG' && do {
$self->_error("CMDARG has been deprecated. "
. "Please use an ALIAS if required.");
next;
};
-
+
# ACTION should be a code ref
$opt eq 'ACTION' && do {
unless (ref($val) eq 'CODE') {
$self->_error("'$opt' value is not a code reference");
next;
};
-
+
# store code ref, forcing keyword to upper case
$self->{ ACTION }->{ $var } = $val;
-
+
next;
};
-
+
# ALIAS creates alias links to the variable name
$opt eq 'ALIAS' && do {
-
+
# coerce $val to an array if not already so
$val = [ split(/\|/, $val) ]
unless ref($val) eq 'ARRAY';
-
+
# fold to lower case unless CASE sensitivity set
unless ($self->{ CASE }) {
@$val = map { lc } @$val;
}
-
+
# store list of aliases...
$self->{ ALIASES }->{ $var } = $val;
-
+
# ...and create ALIAS => VARIABLE lookup hash entries
foreach my $a (@$val) {
$self->{ ALIAS }->{ $a } = $var;
}
-
+
next;
};
-
+
# default
$self->_error("$opt is not a valid configuration item");
}
-
+
# set variable to default value
$self->_default($var);
-
+
# DEBUG: dump new variable definition
if ($DEBUG) {
print STDERR "Variable defined:\n";
@@ -311,7 +311,7 @@ sub set {
if (defined $create
&& ($create eq '1' || $variable =~ /$create/)) {
$self->define($variable);
-
+
print STDERR "Auto-created $variable\n" if $DEBUG;
}
else {
@@ -319,13 +319,13 @@ sub set {
return 0;
}
}
-
+
# call the validate($variable, $value) method to perform any validation
unless ($self->_validate($variable, $value)) {
$self->_error("$variable: invalid value: $value");
return 0;
}
-
+
# DEBUG
print STDERR "$self->set($variable, ",
defined $value
@@ -333,7 +333,7 @@ sub set {
: "<undef>",
")\n"
if $DEBUG;
-
+
# set the variable value depending on its ARGCOUNT
my $argcount = $self->{ ARGCOUNT }->{ $variable };
@@ -400,7 +400,7 @@ sub varlist {
return %set;
}
-
+
#------------------------------------------------------------------------
# AUTOLOAD
#
@@ -436,7 +436,7 @@ sub AUTOLOAD {
# a leading underscore_
if (($attrib = $variable) =~ s/_//g) {
$attrib = uc $attrib;
-
+
if (exists $METHFLAGS{ $attrib }) {
return $self->{ $attrib };
}
@@ -445,17 +445,17 @@ sub AUTOLOAD {
# next parameter should be variable name
$variable = shift;
$variable = $self->_varname($variable);
-
+
# check we've got a valid variable
# $self->_error("$variable: no such variable or method"),
# return undef
# unless exists($self->{ VARIABLE }->{ $variable });
-
+
# return attribute
return $self->{ $attrib }->{ $variable };
}
}
-
+
# set a new value if a parameter was supplied or return the old one
return defined($_[0])
? $self->set($variable, shift)
@@ -497,13 +497,13 @@ sub _configure {
# continue if the attribute is ok to be GLOBAL
next if ($global =~ /(^$global_ok$)/io);
-
+
$self->_error( "\U$global\E parameter cannot be GLOBAL");
}
$self->{ GLOBAL } = $cfg->{ $opt };
next;
};
-
+
# CASE, CREATE and PEDANTIC are stored as they are
$opt =~ /^CASE|CREATE|PEDANTIC$/i && do {
$self->{ uc $opt } = $cfg->{ $opt };
@@ -521,7 +521,7 @@ sub _configure {
$self->_debug($cfg->{ $opt });
next;
};
-
+
# warn about invalid options
$self->_error("\U$opt\E is not a valid configuration option");
}
@@ -577,7 +577,7 @@ sub _varname {
}
}
}
-
+
# return the variable name
$variable;
}
@@ -603,7 +603,7 @@ sub _default {
# hash array, depending on its ARGCOUNT value
my $argcount = $self->{ ARGCOUNT }->{ $variable };
$argcount = AppConfig::ARGCOUNT_ONE unless defined $argcount;
-
+
if ($argcount == AppConfig::ARGCOUNT_NONE) {
return $self->{ VARIABLE }->{ $variable }
= $self->{ DEFAULT }->{ $variable } || 0;
@@ -612,7 +612,7 @@ sub _default {
my $deflist = $self->{ DEFAULT }->{ $variable };
return $self->{ VARIABLE }->{ $variable } =
[ ref $deflist eq 'ARRAY' ? @$deflist : ( ) ];
-
+
}
elsif ($argcount == AppConfig::ARGCOUNT_HASH) {
my $defhash = $self->{ DEFAULT }->{ $variable };
@@ -690,7 +690,7 @@ sub _validate {
# not a ref - assume it's a regex
return $value =~ /$validator/;
};
-
+
# validation failed
return 0;
}
@@ -748,7 +748,7 @@ sub _ehandler {
# check this is a code reference
if (ref($handler) eq 'CODE') {
$self->{ EHANDLER } = $handler;
-
+
# DEBUG
print STDERR "installed new ERROR handler: $handler\n" if $DEBUG;
}
@@ -756,7 +756,7 @@ sub _ehandler {
$self->_error("ERROR handler parameter is not a code ref");
}
}
-
+
return $previous;
}
@@ -847,7 +847,7 @@ sub _dump {
print STDERR
"Status of AppConfig::State (version $VERSION) object:\n\t$self\n";
-
+
print STDERR "- " x 36, "\nINTERNAL STATE:\n";
foreach (qw( CREATE CASE PEDANTIC EHANDLER ERROR )) {
printf STDERR " %-12s => %s\n", $_,
@@ -888,7 +888,7 @@ AppConfig::State - application configuration state
$state->set("foo", 123); # trivial set/get examples
$state->get("foo");
-
+
$state->foo(); # shortcut variable access
$state->foo(456); # shortcut variable update
@@ -912,12 +912,12 @@ appear in your Perl script:
The AppConfig::State module is loaded automatically by the new()
constructor of the AppConfig module.
-
+
AppConfig::State is implemented using object-oriented methods. A
new AppConfig::State object is created and initialised using the
new() method. This returns a reference to a new AppConfig::State
object.
-
+
my $state = AppConfig::State->new();
This will create a reference to a new AppConfig::State with all
@@ -968,7 +968,7 @@ In a config file:
[define]
name = fred # define_name gets created automatically
-
+
[other]
name = john # other_name doesn't - warning raised
@@ -1086,12 +1086,12 @@ a string of names separated by vertical bars, '|'. e.g.:
$state->define("name", {
ALIAS => [ 'person', 'user', 'uid' ],
});
-
+
# or
$state->define("name", {
ALIAS => 'person|user|uid',
});
-
+
$state->user('abw'); # equivalent to $state->name('abw');
=item ARGCOUNT
@@ -1268,8 +1268,6 @@ Be aware that calling C<$state-E<gt>set()> to update the same variable
from within the ACTION function will cause a recursive loop as the
ACTION function is repeatedly called.
-=item
-
=back
=head2 DEFINING VARIABLES USING THE COMPACT FORMAT
@@ -19,7 +19,7 @@ use strict;
use warnings;
use POSIX qw( getpwnam getpwuid );
-our $VERSION = '1.65';
+our $VERSION = '1.67';
our ($AUTOLOAD, $OS, %CAN, %METHOD);
@@ -44,7 +44,7 @@ BEGIN {
getpwnam( defined $_[0] ? shift : '' );
};
}
-
+
# try out each METHOD to see if it's supported on this platform;
# it's important we do this before defining AUTOLOAD which would
# otherwise catch the unresolved call
@@ -67,7 +67,7 @@ BEGIN {
sub new {
my $class = shift;
-
+
my $self = {
METHOD => \%METHOD,
CAN => \%CAN,
@@ -280,8 +280,6 @@ Calls the system function getpwuid() if available and returns the result.
Returns undef if not available. The can_getpwuid() method can be called to
determine if this function is available.
-=item
-
=back
=head1 AUTHOR
@@ -16,7 +16,7 @@ package AppConfig;
use strict;
use warnings;
use base 'Exporter';
-our $VERSION = 1.66;
+our $VERSION = '1.67';
# variable expansion constants
use constant EXPAND_NONE => 0;
@@ -199,37 +199,37 @@ AppConfig - Perl5 module for reading configuration files and parsing command lin
=head1 SYNOPSIS
use AppConfig;
-
+
# create a new AppConfig object
my $config = AppConfig->new( \%cfg );
-
+
# define a new variable
$config->define( $varname => \%varopts );
-
+
# create/define combined
my $config = AppConfig->new( \%cfg,
$varname => \%varopts,
$varname => \%varopts,
...
);
-
+
# set/get the value
$config->set( $varname, $value );
$config->get($varname);
-
+
# shortcut form
$config->varname($value);
$config->varname;
-
+
# read configuration file
$config->file($file);
-
+
# parse command line options
$config->args(\@args); # default to \@ARGV
-
+
# advanced command line options with Getopt::Long
$config->getopt(\@args); # default to \@ARGV
-
+
# parse CGI parameters (GET method)
$config->cgi($query); # default to $ENV{ QUERY_STRING }
@@ -249,14 +249,14 @@ by its configuration when defined.
verbose
nohelp
debug = On
-
+
# single value
home = /home/abw/
-
+
# multiple list value
file = /tmp/file1
file = /tmp/file2
-
+
# multiple hash value
book camel = Programming Perl
book llama = Learning Perl
@@ -284,7 +284,7 @@ Configuration files may be arranged in blocks as per the style of Win32
src = ~/websrc/docs/$site
lib = ~/websrc/lib
dest = ~/public_html/$site
-
+
[page]
header = $lib/header
footer = $lib/footer
@@ -296,7 +296,7 @@ text in a configuration file.
line 1
line 2
FOOBAR
-
+
paths exe = "${PATH}:${HOME}/.bin"
paths link = <<'FOO'
${LD_LIBARRAY_PATH}:${HOME}/lib
@@ -331,9 +331,9 @@ manual page explains:
CPAN stands for the Comprehensive Perl Archive Network.
This is a globally replicated collection of all known Perl
materials, including hundreds of unbundled modules.
-
+
[...]
-
+
For an up-to-date listing of CPAN sites, see
http://www.perl.com/perl/ or ftp://ftp.perl.com/perl/ .
@@ -404,7 +404,7 @@ AppConfig is implemented using object-oriented methods. A
new AppConfig object is created and initialised using the
new() method. This returns a reference to a new AppConfig
object.
-
+
my $config = AppConfig->new();
This will create and return a reference to a new AppConfig object.
@@ -470,7 +470,7 @@ AppConfig::State object:
# create AppConfig
my $config = AppConfig->new('foo', 'bar');
-
+
# methods get passed through to internal AppConfig::State
$config->foo(100);
$config->set('bar', 200);
@@ -507,19 +507,19 @@ constructor are applied by default when variables are created. e.g.
ARGCOUNT => ARGCOUNT_ONE,
}
} );
-
+
$config->define("foo");
$config->define("bar", { ARGCOUNT => ARGCOUNT_NONE } );
is equivalent to:
my $config = AppConfig->new();
-
+
$config->define( "foo", {
DEFAULT => "<undef>",
ARGCOUNT => ARGCOUNT_ONE,
} );
-
+
$config->define( "bar",
DEFAULT => "<undef>",
ARGCOUNT => ARGCOUNT_NONE,
@@ -608,30 +608,30 @@ The following examples demonstrate use of the comapct format, with their
equivalent full specifications:
$config->define("foo|bar|baz!");
-
+
$config->define(
"foo" => {
ALIAS => "bar|baz",
ARGCOUNT => ARGCOUNT_NONE,
});
-
+
$config->define("name=s");
-
+
$config->define(
"name" => {
ARGCOUNT => ARGCOUNT_ONE,
});
-
+
$config->define("file|filelist|f=s@");
-
+
$config->define(
"file" => {
ALIAS => "filelist|f",
ARGCOUNT => ARGCOUNT_LIST,
});
-
+
$config->define("user|u=s%");
-
+
$config->define(
"user" => {
ALIAS => "u",
@@ -817,10 +817,10 @@ Three different expansion types may be applied:
bin = ~/bin # expand '~' to home dir if EXPAND_UID
tmp = ~abw/tmp # as above, but home dir for user 'abw'
-
+
perl = $bin/perl # expand value of 'bin' variable if EXPAND_VAR
ripl = $(bin)/ripl # as above with explicit parens
-
+
home = ${HOME} # expand HOME environment var if EXPAND_ENV
See L<AppConfig::State> for more information on expanding variable values.
@@ -834,7 +834,7 @@ file.
[block1]
foo = 10 # block1_foo = 10
-
+
[block2]
foo = 20 # block2_foo = 20
@@ -891,13 +891,13 @@ is encountered.
myprog -file /tmp/foo -file /tmp/bar # $config->file('/tmp/foo')
# $config->file('/tmp/bar')
-
+
# file => [ '/tmp/foo', '/tmp/bar' ]
-
+
myprog -door "jim=Jim Morrison" -door "ray=Ray Manzarek"
# $config->door("jim=Jim Morrison");
# $config->door("ray=Ray Manzarek");
-
+
# door => { 'jim' => 'Jim Morrison', 'ray' => 'Ray Manzarek' }
See L<AppConfig::Args> for further details on parsing command line
@@ -928,7 +928,7 @@ by a vertical bar '|') and the value of the ARGS parameter.
ARGS => "=i",
ALIAS => "bar|baz",
});
-
+
# Getopt::Long specification: "foo|bar|baz=i"
Errors and warning generated by the Getopt::Long module are trapped and
@@ -963,7 +963,7 @@ The AppConfig::CGI module automatically unescapes the CGI query string
to restore the parameters to their intended values.
http://where.com/mycgi?title=%22The+Wrong+Trousers%22
-
+
# $config->title('"The Wrong Trousers"');
Please be considerate of the security implications of providing writeable
@@ -1026,6 +1026,10 @@ See AppConfig::State for full details of the use of these constants.
=back
+=head1 REPOSITORY
+
+L<https://github.com/neilbowers/AppConfig>
+
=head1 AUTHOR
Andy Wardley, E<lt>abw@wardley.orgE<gt>