in reply to How to print a multi-level Hashes of Hashes and extract parts of it

You have already been given good answers, but I thought I could share here some code that I wrote for an answer I made about five days ago to a similar question on another forum (http://perlguru.com/gforum.cgi?post=80741;guest=19041527. It provides a very sketchy and incomplete prototype implementation of a dumper function somewhat similar to the Data::Dumper module (but much less advanced). The data sample used in this example is not yours, but you could very easily replace the content of the $response variable below with your own data sample.
use strict; use warnings; my $response = { 'items' => [], 'messages' => [], 'status' => 1, 'total_results' => 1, 'xmlref' => { 'Items' => [ { 'ASIN' => 'B00PXMMHMY', 'BrowseNodes' => { 'BrowseNode' => [ { 'Ancestors' => { 'BrowseNode' => { 'BrowseNodeId' => '3146281', 'Name' => 'Home & Garden' } }, }, { 'Ancestors2' => { 'BrowseNode2' => { 'BrowseNodeId' => '3146282', 'Name' => 'Garden & home' } }, } ] } } ] } }; dumper (0, ref $response, $response); sub dumper { my ($level , $ref_type_in, $reference) = @_; if ($ref_type_in eq 'ARRAY' ) { for my $value (@$reference) { my $ref_type_out = ref $value; if ($ref_type_out) { dumper ($level + 1, $ref_type_out, $va +lue) } else { print "\t" x $level; print $value, "\n +"; } } } elsif ($ref_type_in eq 'HASH' ) { for my $key (keys %$reference) { print "\t" x $level, $key, " => "; my $value = $reference->{$key}; my $ref_type_out = ref $value; if ($ref_type_out) { print "\n"; dumper ($level + 1, $ref_type_out, $va +lue) } else { print $value, "\n"; } } } else { print "Unknown reference type\n"; } }
The output is far from being as rich as Data::Dumper and offers a lot of opportunities for improvement, but let's say that we have a reasonably good proof of concept. My aim for this post on the other forum was anyway not to write a replacement for Data::Dumper, but only to demonstrate how to traverse a nested data structure in which the nodes might be hash or array references.
xmlref => Items => ASIN => B00PXMMHMY BrowseNodes => BrowseNode => Ancestors => BrowseNode => BrowseNodeId => 3146281 Name => Home & Garden Ancestors2 => BrowseNode2 => BrowseNodeId => 3146282 Name => Garden & home messages => total_results => 1 status => 1 items =>
And, BTW, my approach is also recursive. I do not think that I need to repeat how recursion is important, others have stated it quite clearly.

Je suis Charlie.