NAME
Datify::Path - Describe structures like filesystem paths.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/rkleemann/Datify/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
VERSION
version 0.18.277
AUTHOR
Bob Kleemann <bobk@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014-2018 by Bob Kleemann.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
SYNOPSIS
use Datify::Path;
my $pathify = Datify::Path->new();
say foreach $pathify->pathify( [ qw( this that the-other ) ] );
# [1/3] = this
# [2/3] = that
# [3/3] = 'the-other'
say foreach $pathify->pathify( { a => 100, b => 1024, c => 102030 } );
# /a = 100
# /b = 1_024
# /c = 102_030
say foreach $pathify->pathify(
{
array => [ 1, 10, 100, 10000, 100_000_000 ],
hash => { a => 'alpha', b => 'bravo', c => undef },
nested => [
{ '!@#$%^&*()' => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ] },
{ '' => 'empty string' },
{ " \t\n" => 'space, tab, & newline' },
{ 'empty array' => [] },
{ 'empty hash' => {} },
],
}
);
# /array[1/5] = 1
# /array[2/5] = 10
# /array[3/5] = 100
# /array[4/5] = 10_000
# /array[5/5] = 100_000_000
# /hash/a = alpha
# /hash/b = bravo
# /hash/c
# /nested[1/4]/'!@#$%^&*()'[ 1/10] = 1
# /nested[1/4]/'!@#$%^&*()'[ 2/10] = 2
# /nested[1/4]/'!@#$%^&*()'[ 3/10] = 3
# /nested[1/4]/'!@#$%^&*()'[ 4/10] = 4
# /nested[1/4]/'!@#$%^&*()'[ 5/10] = 5
# /nested[1/4]/'!@#$%^&*()'[ 6/10] = 6
# /nested[1/4]/'!@#$%^&*()'[ 7/10] = 7
# /nested[1/4]/'!@#$%^&*()'[ 8/10] = 8
# /nested[1/4]/'!@#$%^&*()'[ 9/10] = 9
# /nested[1/4]/'!@#$%^&*()'[10/10] = 0
# /nested[2/4]/'' = 'empty string'
# /nested[3/4]/" \t\n" = 'space, tab, & newline'
# /nested[4/4]/'empty array'[0/0]
# /nested[4/4]/'empty hash'/
DESCRIPTION
Datify::Path will convert a data structure consisting of arrays, hashes, and scalars into a form similar to a path listing. This can be useful when searching for a particular value, then finding the "path" that leads to it.