Data::Context::Util - Helper functions for Data::Context
This documentation refers to Data::Context::Util version 0.1.6.
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
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.
lol_path
All errors result in returning no value.
lol_iterate ($lol, $code)
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
There are no known bugs in this module.
Please report problems to Ivan Wills (ivan.wills@gmail.com).
Patches are welcome.
Ivan Wills - (ivan.wills@gmail.com)
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.
To install Data::Context, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Context
CPAN shell
perl -MCPAN -e shell install Data::Context
For more information on module installation, please visit the detailed CPAN module installation guide.