The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 option values.

schema

TODO

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).

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.

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.

Methods *_array() return a list of elements, which in scalar context turns out to be a number.

Methods *_hash() return a hashref (or undef) 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_ and top_ are reserved. Use explicit get() 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.

SEE ALSO

App::Getconf(3)