#!perl
use Modern::Perl;
use Moose::Util qw( with_traits );
use Data::Walk::Extracted 0.017;
use Data::Walk::Graft 0.011;
use Data::Walk::Print 0.013;
my $gardener = with_traits(
'Data::Walk::Extracted',
(
'Data::Walk::Graft',
'Data::Walk::Clone',
'Data::Walk::Print',
),
)->new(
sorted_nodes =>{
HASH => 1,
},# For demonstration consistency
graft_memory => 1,
);
my $tree_ref = {
Helping =>{
KeyTwo => 'A New Value',
KeyThree => 'Another Value',
OtherKey => 'Something',
},
MyArray =>[
'ValueOne',
'ValueTwo',
'ValueThree',
],
};
$gardener->graft_data(
scion_ref =>{
Helping =>{
OtherKey => 'Otherthing',
},
MyArray =>[
'IGNORE',
{
What => 'Chicken_Butt!',
},
'IGNORE',
'IGNORE',
'ValueFive',
],
},
tree_ref => $tree_ref,
);
$gardener->print_data( $tree_ref );
print "Now a list of -" . $gardener->number_of_scions .
"- grafted positions\n";
$gardener->print_data( $gardener->get_grafted_positions );
############################################################
# Output of SYNOPSIS
# 01 {
# 02 Helping => {
# 03 KeyThree => 'Another Value',
# 04 KeyTwo => 'A New Value',
# 05 OtherKey => 'Otherthing',
# 06 },
# 07 MyArray => [
# 08 'ValueOne',
# 09 {
# 10 What => 'Chicken_Butt!',
# 11 },
# 12 'ValueThree',
# 13 ,
# 14 'ValueFive',
# 15 ],
# 16 },
# 17 Now a list of -3- grafted positions
# 18 [
# 19 {
# 20 Helping => {
# 21 OtherKey => 'Otherthing',
# 22 },
# 23 },
# 24 {
# 25 MyArray => [
# 26 ,
# 27 {
# 28 What => 'Chicken_Butt!',
# 29 },
# 30 ],
# 31 },
# 32 {
# 33 MyArray => [
# 34 ,
# 35 ,
# 36 ,
# 37 ,
# 38 'ValueFive',
# 39 ],
# 40 },
# 41 ],
############################################################
It is still in development but the API shouldn't change substantially. Feel free to use the module or leverage the source to your preference.