1AppConfig::Std(3)     User Contributed Perl Documentation    AppConfig::Std(3)
2
3
4

NAME

6       AppConfig::Std - subclass of AppConfig that provides standard options
7

SYNOPSIS

9           use AppConfig::Std;
10
11           $config = AppConfig::Std->new();
12
13           # all AppConfig methods supported
14           $config->define('foo');            # define variable foo
15           $config->set('foo', 25);           # setting a variable
16           $val = $config->get('foo');        # getting variable
17           $val = $config->foo();             # shorthand for getting
18
19           $config->args(\@ARGV);             # parse command-line
20           $config->file(".myconfigrc")       # read config file
21

DESCRIPTION

23       AppConfig::Std is a Perl module that provides a set of standard
24       configuration variables and command-line switches.  It is implemented
25       as a subclass of AppConfig; AppConfig provides a general mechanism for
26       handling global configuration variables.
27
28       The features provided by AppConfig::Std are:
29
30       ·   Standard command-line arguments: -help, -doc, -version, -verbose,
31           and -debug. AppConfig::Std handles the -help, -doc, and -version
32           switches for you, so you don't need to duplicate that code in all
33           of your scripts.  These are described below.
34
35       ·   The ARGCOUNT default is set to 1. This means that by default all
36           switches are expected to take a value. To change this, set the
37           ARGCOUNT parameter when defining the variable:
38
39               $config->define('verbose', { ARGCOUNT => 0 } );
40
41       Please read the copious documentation for AppConfig to find out what
42       else you can do with this module.
43

STANDARD OPTIONS

45       The module adds five standard configuration variables and command-line
46       switches. You can define additional variables as you would with
47       AppConfig.
48
49   HELP
50       The -help switch will result in a short help message.  This is
51       generated using Pod::Usage, which displays the OPTIONS section of your
52       pod. The script will exit with an exit value of 0.
53
54   DOC
55       The -doc switch will result in the entire documentation being formatted
56       to the screen.  This is also done with Pod::Usage.  The script will
57       exit with an exit value of 0.
58
59   VERSION
60       The -version switch will display the version of the invoking script.
61       This assumes that you have defined $VERSION in your script with
62       something like the following:
63
64           use vars qw( $VERSION );
65           $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
66
67       The script will exit with an exit value of 0.
68
69   DEBUG
70       The -debug switch just sets the debug variable.  This is useful for
71       displaying information in debug mode:
72
73           $foobar->dump() if $config->debug;
74
75   VERBOSE
76       The -verbose switch just sets the verbose variable.  This is useful for
77       displaying verbose information as a script runs:
78
79           print STDERR "Running foobar\n" if $config->verbose;
80

TODO

82       Please let me know if you have ideas for additional switches, or other
83       modifications. Things currently being mulled:
84
85       ·   Support brief switches, such as -h as well as -help.  This could be
86           a config option for the constructor.
87
88       ·   Include a sample script called mkscript, which would create a
89           template script along with Makefile.PL, MANIFEST, etc.  Kinda of a
90           h2xs for scripts.
91

EXAMPLE

93       The following is the outline of a simple script that illustrates use of
94       the AppConfig::Std module:
95
96           #!/usr/bin/perl -w
97           use strict;
98           use AppConfig::Std;
99
100           use vars qw( $VERSION );
101           $VERSION = '1.0';
102
103           my $config = AppConfig::Std->new();
104
105           # parse command-line and handle std switches
106           $config->args(\@ARGV);
107
108           exit 0;
109
110           __END__
111
112           =head1 NAME
113
114           standard pod format documentation
115
116       The pod documentation is expected to have the NAME, SYNOPSIS,
117       DESCRIPTION, and OPTIONS sections. See the documentation for "pod2man"
118       for more details.
119

SEE ALSO

121       AppConfig
122           Andy Wardley's module for unifying command-line switches and
123           cofiguration files into the notion of configuration variables.
124           AppConfig::Std requires version 1.52+ of the module, which is
125           available from CPAN:
126
127               http://www.cpan.org/modules/by-module/AppConfig/
128
129       Pod::Usage
130           Brad Appleton's module for extracting usage information out of a
131           file's pod. This is used for the -doc and -help switches.
132           Available from CPAN as part of the PodParser distribution:
133
134               http://www.cpan.org/modules/by-module/Pod/
135
136       perlpod
137           Documentation from the perl distribution that describes the pod
138           format.
139
140       pod2man
141           Particularly the NOTES section in the documentation which describes
142           the sections you should include in your documentation.
143           AppConfig::Std uses Pod::Usage, which assumes well-formed pod.
144

AUTHOR

146       Neil Bowers <neil@bowers.com>
147
149       Copyright (c) 2002 Neil Bowers.
150
151       Copyright (c) 1998-2001 Canon Research Centre Europe. All rights
152       reserved.
153
154       This script is free software; you can redistribute it and/or modify it
155       under the same terms as Perl itself.
156
157
158
159perl v5.12.0                      2002-07-02                 AppConfig::Std(3)
Impressum