Ivan Wills

NAME

Data::Context::Util - Helper functions for Data::Context

VERSION

This documentation refers to Data::Context::Util version 0.1.10.

SYNOPSIS

   use Data::Context::Util qw/lol_path lol_iterate/;

   my $lol = {
        data => [
            {
                structure => 'item',
            },
        ],
   };

   my $value = lol_path($lol, 'data.0.structure');
   # value == item

   lol_iterate(
        $lol,
        sub {
            my ($value, $path) = @_;
            print "$path = $value" if !ref $value;
        }
   );
   # would print data.0.structure = item

DESCRIPTION

SUBROUTINES/METHODS

lol_path ( $lol, $path )

$lol

List of lists ie an arbitrary data structure

$path

A string encoded as a dotted path through the data structure

lol_path tries to extract data from an arbitrary Perl data structure based on the specified path. It will try yo do what makes sense ie if the current context of the lol is a hash the path part will be used as a key, similarly if the context is an array the path part will be used as an index. If the context is a blessed reference then it try to call the path part as a method.

All errors result in returning no value.

lol_iterate ($lol, $code)

$lol

Arbitrary perl data structure

$code

A subroutine that is called against all values found in the data structure. It is called as:

 $code->($value, $path);

Recursively iterates through a data structure calling $code for each value encountered.

do_require ($module)

Requires the specified module (if not previously required

DIAGNOSTICS

CONFIGURATION AND ENVIRONMENT

DEPENDENCIES

INCOMPATIBILITIES

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Ivan Wills (ivan.wills@gmail.com).

Patches are welcome.

AUTHOR

Ivan Wills - (ivan.wills@gmail.com)

LICENSE AND COPYRIGHT

Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.