The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

Version 2.65

REVISION

$Revision: 180 $

SYNOPSIS

    use CTK;
    use CTK::ConfGenUtil;
    my $c = new CTK;
    my $config = $c->config;
    
    # <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 );
    say "Is scalar : ", is_scalar($config, 'foo/bar/baz') ? 'OK' : 'NO'; # OK
    
    is_array( $foo );
    say "Is array  : ", is_array($config, 'foo/bar/qux') ? 'OK' : 'NO'; # OK
    
    is_hash( $foo );
    say "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' );
exists

Reserved. Coming soon

This method returns just true if the given key exists in the config.

SEE ALSO

Config::General::Extended

AUTHOR

Serz Minus (Lepenkov Sergey) http://www.serzik.com <minus@mail333.com>

COPYRIGHT

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

LICENSE

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

This program is distributed under the GNU LGPL v3 (GNU Lesser General Public License version 3).

See LICENSE file