The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Config::Maker::Option - One configuration element.

SYNOPSIS

  use Config::Maker

  # Only constructed from the config parser
  
  $option->type
  $option->id
  "$option"

  $option->get($path)
  $option->get1($path)
  $option->getval($path, $default)

DESCRIPTION

Config::Maker::Option objects represent individual elements of the configuration.

Each Config::Maker::Option object has three attributes. The -type, which is a Config::Maker::Type object, the -value, which is a string and the -children which is a list of Config::Maker::Option objects.

The type can be accessed via the type method (read-only), and the value may be accessed by simple stringification. The id method is useful for reporting option in errors.

In addition to basic access, there are several convenience methods for doing path lookups. They are esentialy reversed Config::Maker::Path::find method, but they can construct the path from a string.

get

This is the simplest one. It is just calls Config::Maker::Path::find with invocant as a starting element, constructing the path with Config::Maker::Path::make if it get's a string. See Config::Maker::Path.

Unlike find, which returns an arrayref, this returns a list in list context and first match in scalar context.

get1

This is like get above, but it signal an error unless the path matches exactly one element.

getval

This method takes an extra argument, a default. If the path does not match, it returns the default. If it matches once, it returns the match. If it matches more than once, it signals an error.

AUTHOR

Jan Hudec <bulb@ucw.cz>

COPYRIGHT AND LICENSE

Copyright 2004 Jan Hudec. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

configit(1), perl(1), Config::Maker(3pm).