NAME
Config::Hierarchical::Tie::ReadOnly - Access Hierarchical configuration container through a read only hash
SYNOPSIS
my $config = new Config::Hierarchical
(
NAME => 'config',
CATEGORY_NAMES => ['A', 'B'],
DEFAULT_CATEGORY => 'B',
INITIAL_VALUES =>
[
{CATEGORY => 'A', NAME => 'CC1', VALUE => '1'},
{CATEGORY => 'B', NAME => 'CC2', VALUE => '2'},
{CATEGORY => 'A', NAME => 'CC3', VALUE => '3'},
{CATEGORY => 'B', NAME => 'CC4', VALUE => '4'},
{CATEGORY => 'A', NAME => 'CC5', VALUE => '5'},
] ,
) ;
my %hash ;
tie %hash, 'Config::Hierarchical::Tie::ReadOnly' => $config ;
my @keys = sort keys %hash ; # qw( CC1 CC2 CC3 CC4 CC5)
print $hash{CC1} ; # print '1'
$hash{CC1} = 2 ; # dies, hash is read only
DESCRIPTION
Creates a read only wrapper around a Config::Hierarchical object. This let's you access the config object as a hash. You can use {} access which makes it easy to use the config in interpolated string. You can also use keys and each on the tied config.
but you can't modify the variables, clear the config or delete any variable.
This is also class is also used to allow you to link a category to an existing Config::Hierarchical object. See new in <Config::Hierarchical>.
DOCUMENTATION
SUBROUTINES/METHODS
TIEHASH
The method invoked by the command tie %hash, class name. Associates a new hash instance with the specified class.
STORE
Dies as this tie is read only.
FETCH
Retrieve the value associated with the configuration variable passed as argument
FIRSTKEY
Return the first key in the hash. Used internally by Perl.
NEXTKEY
Return the next key in the hash. Used internally by Perl.
EXISTS
Verify that key exists within the tied Config::Hierarchical.
DELETE
Dies as this tie is read only.
CLEAR
Dies as this tie is read only.
SCALAR
returns the number of elements in the tied Config::Hierarchical object.
BUGS AND LIMITATIONS
None so far.
AUTHOR
Khemir Nadim ibn Hamouda
CPAN ID: NKH
mailto:nadim@khemir.net
LICENSE AND COPYRIGHT
Copyright 2007 Khemir Nadim. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Config::Hierarchical
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
RT: CPAN's request tracker
Please report any bugs or feature requests to L <bug-config-hierarchical@rt.cpan.org>.
We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
Search CPAN