CTK::ConfGenUtil - Config::General structure utility functions
Version 2.68
use CTK::ConfGenUtil; # <Foo> # <Bar> # Baz qux # </Bar> # </Foo> my $foo = node( $config, 'foo' ); # { bar => { baz => 'qux' } } my $bar = node( $config, 'foo', 'bar' ); # { baz => 'qux' } my $bar = node( $config, ['foo', 'bar'] ); # { baz => 'qux' } my $bar = node( $config, 'foo/bar' ); # { baz => 'qux' } my $baz = value( $config, 'foo/bar/baz' ); # qux # Foo bar my $foo = value( $config, 'foo' ); # bar # Foo 123 # Foo 456 # Foo 789 my $foo = array( $config, 'foo' ); # [123,456,789] # <Foo> # Bar baz # </Foo> my $foo = hash( $config, 'foo' ); # { bar => 'baz' } # <Foo> # <Bar> # Baz blah-blah-blah # Qux 123 # Qux 456 # Qux 789 # </Bar> # </Foo> is_scalar( $foo ); print "Is scalar : ", is_scalar($config, 'foo/bar/baz') ? 'OK' : 'NO'; # OK is_array( $foo ); print "Is array : ", is_array($config, 'foo/bar/qux') ? 'OK' : 'NO'; # OK is_hash( $foo ); print "Is hash : ", is_hash($config, 'foo/bar') ? 'OK' : 'NO'; # OK
This module based on Config::General::Extended
Working sample:
<Foo> <Bar> Baz blah-blah-blah Qux 123 Qux 456 Qux 789 </Bar> </Foo>
This method returns the found node of a given key.
my $bar = node( $config, 'foo', 'bar' ); my $bar = node( $config, ['foo', 'bar'] ); my $bar = node( $config, 'foo/bar' ); my $bar = node( $config, ['foo/bar'] ); my $bar_hash = hash($bar); my $baz = value($bar, 'baz'); # blah-blah-blah
This method returns the scalar value of a given key.
my $baz = value( $config, 'foo/bar/baz' );
This method returns a array reference (if it is one!) from the config which is referenced by "key". Given the sample config above you would get:
my $qux = array( $config, 'foo/bar/qux' );
This method returns a hash reference (if it is one!) from the config which is referenced by "key". Given the sample config above you would get:
my $bar = hash( $config, 'foo/bar' );
As seen above, you can access parts of your current config using hash, array or scalar functions. This function returns just true if the given key is scalar (regular value)
is_scalar( $baz ); is_scalar( $config, 'foo/bar/baz' );
As seen above, you can access parts of your current config using hash, array or scalar functions. This function returns just true if the given key is array (reference)
is_array( $qux ); is_array( $config, 'foo/bar/qux' );
As seen above, you can access parts of your current config using hash, array or scalar functions. This function returns just true if the given key is hash (reference)
is_hash( $bar ); is_hash( $config, 'foo/bar' );
See Changes file
Changes
See TODO file
TODO
* none noted
Config::General::Extended
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE file and https://dev.perl.org/licenses/
LICENSE
To install CTK, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CTK
CPAN shell
perl -MCPAN -e shell install CTK
For more information on module installation, please visit the detailed CPAN module installation guide.