1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
4 .\" ========================================================================
5 .de Sh \" Subsection heading
13 .de Sp \" Vertical space (when we can't use .PP)
17 .de Vb \" Begin verbatim text
22 .de Ve \" End verbatim text
26 .\" Set up some character translations and predefined strings. \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote. | will give a
29 .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
37 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD. Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
57 . tm Index:\\$1\t\\n%\t"\\$2"
63 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear. Run. Save yourself. No user-serviceable parts.
70 . \" fudge factors for nroff and troff
79 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
85 . \" simple accents for nroff and troff
95 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
102 . \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 . \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 . \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
129 .\" ========================================================================
131 .IX Title "AppConfig::File 3"
132 .TH AppConfig::File 3 "2007-05-30" "perl v5.8.7" "User Contributed Perl Documentation"
134 AppConfig::File \- Perl5 module for reading configuration files.
136 .IX Header "SYNOPSIS"
138 \& use AppConfig::File;
142 \& my $state = AppConfig::State\->new(\e%cfg1);
143 \& my $cfgfile = AppConfig::File\->new($state, $file);
147 \& $cfgfile\->parse($file); # read config file
150 .IX Header "OVERVIEW"
151 AppConfig::File is a Perl5 module which reads configuration files and use
152 the contents therein to update variable values in an AppConfig::State
155 AppConfig::File is distributed as part of the AppConfig bundle.
157 .IX Header "DESCRIPTION"
158 .Sh "\s-1USING\s0 \s-1THE\s0 AppConfig::File \s-1MODULE\s0"
159 .IX Subsection "USING THE AppConfig::File MODULE"
160 To import and use the AppConfig::File module the following line should appear
164 \& use AppConfig::File;
167 AppConfig::File is used automatically if you use the AppConfig module
168 and create an AppConfig::File object through the \fIfile()\fR method.
170 AppConfig::File is implemented using object-oriented methods. A new
171 AppConfig::File object is created and initialised using the
172 AppConfig::File\->\fInew()\fR method. This returns a reference to a new
173 AppConfig::File object. A reference to an AppConfig::State object
174 should be passed in as the first parameter:
177 \& my $state = AppConfig::State\->new();
178 \& my $cfgfile = AppConfig::File\->new($state);
181 This will create and return a reference to a new AppConfig::File object.
182 .Sh "\s-1READING\s0 \s-1CONFIGURATION\s0 \s-1FILES\s0"
183 .IX Subsection "READING CONFIGURATION FILES"
184 The \f(CW\*(C`parse()\*(C'\fR method is used to read a configuration file and have the
185 contents update the \s-1STATE\s0 accordingly.
188 \& $cfgfile\->parse($file);
191 Multiple files maye be specified and will be read in turn.
194 \& $cfgfile\->parse($file1, $file2, $file3);
197 The method will return an undef value if it encounters any errors opening
198 the files. It will return immediately without processing any further files.
199 By default, the \s-1PEDANTIC\s0 option in the AppConfig::State object,
200 \&\f(CW$self\fR\->{ \s-1STATE\s0 }, is turned off and any parsing errors (invalid variables,
201 unvalidated values, etc) will generated warnings, but not cause the method
202 to return. Having processed all files, the method will return 1 if all
203 files were processed without warning or 0 if one or more warnings were
204 raised. When the \s-1PEDANTIC\s0 option is turned on, the method generates a
205 warning and immediately returns a value of 0 as soon as it encounters any
208 Variables values in the configuration files may be expanded depending on
209 the value of their \s-1EXPAND\s0 option, as determined from the App::State object.
210 See AppConfig::State for more information on variable expansion.
211 .Sh "\s-1CONFIGURATION\s0 \s-1FILE\s0 \s-1FORMAT\s0"
212 .IX Subsection "CONFIGURATION FILE FORMAT"
213 A configuration file may contain blank lines and comments which are
214 ignored. Comments begin with a '#' as the first character on a line
215 or following one or more whitespace tokens, and continue to the end of
219 \& # this is a comment
220 \& foo = bar # so is this
221 \& url = index.html#hello # this too, but not the '#welcome'
224 Notice how the '#welcome' part of the \s-1URL\s0 is not treated as a comment
225 because a whitespace character doesn't precede it.
227 Long lines can be continued onto the next line by ending the first
231 \& callsign = alpha bravo camel delta echo foxtrot golf hipowls \e
232 \& india juliet kilo llama mike november oscar papa \e
233 \& quebec romeo sierra tango umbrella victor whiskey \e
234 \& x\-ray yankee zebra
237 Variables that are simple flags and do not expect an argument (\s-1ARGCOUNT\s0 =
238 \&\s-1ARGCOUNT_NONE\s0) can be specified without any value. They will be set with
239 the value 1, with any value explicitly specified (except \*(L"0\*(R" and \*(L"off\*(R")
240 being ignored. The variable may also be specified with a \*(L"no\*(R" prefix to
241 implicitly set the variable to 0.
245 \& verbose = 1 # on (1)
246 \& verbose = 0 # off (0)
247 \& verbose off # off (0)
248 \& verbose on # on (1)
249 \& verbose mumble # on (1)
250 \& noverbose # off (0)
253 Variables that expect an argument (\s-1ARGCOUNT\s0 = \s-1ARGCOUNT_ONE\s0) will be set to
254 whatever follows the variable name, up to the end of the current line. An
255 equals sign may be inserted between the variable and value for clarity.
258 \& room = /home/kitchen
259 \& room /home/bedroom
262 Each subsequent re-definition of the variable value overwrites the previous
266 \& print $config\->room(); # prints "/home/bedroom"
269 Variables may be defined to accept multiple values (\s-1ARGCOUNT\s0 = \s-1ARGCOUNT_LIST\s0).
270 Each subsequent definition of the variable adds the value to the list of
271 previously set values for the variable.
278 A reference to a list of values is returned when the variable is requested.
281 \& my $beverages = $config\->drinks();
282 \& print join(", ", @$beverages); # prints "coffee, tea"
285 Variables may also be defined as hash lists (\s-1ARGCOUNT\s0 = \s-1ARGCOUNT_HASH\s0).
286 Each subsequent definition creates a new key and value in the hash array.
293 A reference to the hash is returned when the variable is requested.
296 \& my $aliases = $config\->alias();
297 \& foreach my $k (keys %$aliases) {
298 \& print "$k => $aliases\->{ $k }\en";
302 A large chunk of text can be defined using Perl's \*(L"heredoc\*(R" quoting
306 \& scalar = <<BOUNDARY_STRING
308 \& line 2: Space/linebreaks within a HERE document are kept.
309 \& line 3: The last linebreak (\en) is stripped.
314 \& hash key1 = <<'FOO'
315 \& * Quotes (['"]) around the boundary string are simply ignored.
316 \& * Whether the variables in HERE document are expanded depends on
317 \& the EXPAND option of the variable or global setting.
322 \& hash = key2 = <<"_bar_"
323 \& Text within HERE document are kept as is.
324 \& # comments are treated as a normal text.
325 \& The same applies to line continuation. \e
329 Note that you cannot use \s-1HERE\s0 document as a key in a hash or a name
332 The '\-' prefix can be used to reset a variable to its default value and
333 the '+' prefix can be used to set it to 1
340 Variable, environment variable and tilde (home directory) expansions
341 Variable values may contain references to other AppConfig variables,
342 environment variables and/or users' home directories. These will be
343 expanded depending on the \s-1EXPAND\s0 value for each variable or the \s-1GLOBAL\s0
344 \&\s-1EXPAND\s0 value.
346 Three different expansion types may be applied:
349 \& bin = ~/bin # expand '~' to home dir if EXPAND_UID
350 \& tmp = ~abw/tmp # as above, but home dir for user 'abw'
354 \& perl = $bin/perl # expand value of 'bin' variable if EXPAND_VAR
355 \& ripl = $(bin)/ripl # as above with explicit parens
359 \& home = ${HOME} # expand HOME environment var if EXPAND_ENV
362 See AppConfig::State for more information on expanding variable values.
364 The configuration files may have variables arranged in blocks. A block
365 header, consisting of the block name in square brackets, introduces a
366 configuration block. The block name and an underscore are then prefixed
367 to the names of all variables subsequently referenced in that block. The
368 block continues until the next block definition or to the end of the current
373 \& foo = 10 # block1_foo = 10
378 \& foo = 20 # block2_foo = 20
382 Andy Wardley, <abw@wardley.org>
384 .IX Header "COPYRIGHT"
385 Copyright (C) 1997\-2007 Andy Wardley. All Rights Reserved.
387 This module is free software; you can redistribute it and/or modify it
388 under the same terms as Perl itself.
390 .IX Header "SEE ALSO"
391 AppConfig, AppConfig::State