Author image Dominic Mitchell

NAME

Config::Setting::Chunk - Representation of a configuration file

SYNOPSIS

  use Config::Setting::Chunk;

  my $chunk = Config::Setting::Chunk->new;
  $chunk->add_section( "login" );
  $chunk->set_item( "login", "username", "fred" );

  my @sections = $chunk->sections;
  my $username = $chunk->get_item( "login", "username" );

DESCRIPTION

This class is a representation of a configuration file. A chunk consists of zero or more sections, each of which consists of zero or more items.

METHODS

new ( )

Class Method. Constructor.

add_section ( SECTION )

Create a new section named SECTION. Has no effect if SECTION is already present in this chunk.

sections ( )

Return a list of all sections in this chunk, in the order in which they were added.

has_section ( SECTION )

Returns true or false if SECTION is present or not in this chunk.

section_keys ( SECTION )

Returns a list of all keys present in SECTION.

set_item ( SECTION, KEY, VALUE )

Set the item KEY to have VALUE in SECTION. if SECTION does not exist, it will be created.

get_item ( SECTION, KEY )

Return the value of KEY in SECTION. Returns undef if KEY or SECTION does not exist.

get ( KEY )

Return the value of KEY in the first section which contains it, or undef if no section contains it.

to_string ( )

Returns the chunk in windows .INI style format. This may be useful for debugging.

AUTHOR

Dominic Mitchell, <cpan (at) happygiraffe.net>

SEE ALSO

Config::Setting.