App::Getconf::View - specific view of options set in App::Getconf
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; }
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 prefix option passed to the constructor.
get($option_name)
Retrieve value of option $option_name. Method performs lookup, consequently prepending each of prefixes (see prefixes() method).
$option_name
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() and top(), 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.
get()
top()
get_*()
Methods die() when no matching option was found. If the option was found but it had not been set, methods return undef or empty list, whichever is appropriate.
die()
undef
Methods *_array() return a list of elements, which in scalar context turns out to be a number.
*_array()
Methods *_hash() return a hashref (or undef) in scalar context and list of key/value pairs in list context.
*_hash()
${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.
$view->get('verbose')
$view->verbose
Note that this syntax performs lookup, just like get() method.
Names starting with set_, get_ and top_ are reserved. Use explicit get() method call to retrieve them.
set_
get_
top_
Stanislaw Klekot, <cpan at jarowit.net>
<cpan at jarowit.net>
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.
App::Getconf(3)
To install App::Getconf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Getconf
CPAN shell
perl -MCPAN -e shell install App::Getconf
For more information on module installation, please visit the detailed CPAN module installation guide.