NAME
App::Getconf::View - specific view of options set in App::Getconf
SYNOPSIS
use App::Getconf;
App::Getconf->schema(...);
App::Getconf->cmdline(\@ARGV);
my $view = App::Getconf->getopt;
if ($view->help) {
print "this is --help message\n";
exit 0;
}
print "starting the program\n" if $view->verbose;
for my $i (0 .. $view->get("bottles.number")) {
printf "%d bottles of beer on the wall, %d bottles of beer.\n" .
"Take one down and pass it around, %d bottles of beer on the wall.\n\n",
99 - $i, 99 - $i, 99 - $i - 1;
}
METHODS
Following methods are available:
new(%opts)-
Constructor. Typically you won't be calling this on your own, so don't be excited.
Following options are honoured:
prefix-
Longest prefix for options ("." is a separator). All other prefixes that will be tried in lookup have last component chopped off, compared to previous prefix.
options-
Hashref containing all the App::Getconf::Node(3) objects.
prefixes()-
List of prefixes searched by this view.
Prefixes are composed from
prefixoption passed to the constructor. get($option_name)-
Retrieve value of option
$option_name. Method performs lookup, consequently prepending each of prefixes (seeprefixes()method). top($option_name)-
Retrieve value of option
$option_name. Method does not perform lookup. You'll get the option which you asked for. get_{flag|bool|int|float|string}()top_{flag|bool|int|float|string}()get_{flag|bool|int|float|string}_array()top_{flag|bool|int|float|string}_array()get_{flag|bool|int|float|string}_hash()top_{flag|bool|int|float|string}_hash()-
Methods similar to
get()andtop(), but they also check if the result is of matching type (get_*()don't stop on non-matching options). Option storage is also checked: it should be, respectively, a scalar, an array or a hash.Methods
die()when no matching option was found. If the option was found but it had not been set, methods returnundefor empty list, whichever is appropriate.Methods
*_array()return a list of elements, which in scalar context turns out to be a number.Methods
*_hash()return a hashref (orundef) in scalar context and list of key/value pairs in list context. ${option_name}()-
For convenience, options may be retrieved by calling method named after the option. For example, following two are equivalent:
$view->get('verbose')and$view->verbose.Note that this syntax performs lookup, just like
get()method.Names starting with
set_,get_andtop_are reserved. Use explicitget()method call to retrieve them.
AUTHOR
Stanislaw Klekot, <cpan at jarowit.net>
LICENSE AND COPYRIGHT
Copyright 2012 Stanislaw Klekot.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.