NAME

CTK::ConfGenUtil - Config::General structure utility functions

VERSION

Version 2.68

SYNOPSIS

    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

DESCRIPTION

This module based on Config::General::Extended

FUNCTIONS

Working sample:

    <Foo>
      <Bar>
        Baz blah-blah-blah
        Qux 123
        Qux 456
        Qux 789
      </Bar>
    </Foo>
node

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
value

This method returns the scalar value of a given key.

    my $baz = value( $config, 'foo/bar/baz' );
array

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' );
hash

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' );
is_scalar, is_value

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' );
is_array

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' );
is_hash

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' );

HISTORY

See Changes file

TO DO

See TODO file

BUGS

* none noted

SEE ALSO

Config::General::Extended

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

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/