in reply to Re^4: XML::Simple Multi-Layered
in thread XML::Simple Multi-Layered

For the sake of example I've stripped down the data to just leave the bits we're looking at. (note the $Data::Dumper::Indent = 1; line, it compacts Dumper's output a bit).

You have a series of nested hash of arrays (HoAs).

Here I've extracted the array ref we want and looped over it.

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; $Data::Dumper::Indent = 1; # more compact output my $h = data(); my $intervals = $h-> {client_system}[0] {business_area}[0] {component}[0] {component_lib}[0] {class_set}[0] {base_class_set}[0] {interval}; for my $interval (@{$intervals}){ print $interval->{name}, "\n"; } sub data { return { 'client_system' => [ { 'business_area' => [ { 'component' => [ { 'component_lib' => [ { 'class_set' => [ { 'base_class_set' => [ { 'interval' => [ {'name' => 'low-199'}, {'name' => '200-499'}, {'name' => '500-899'}, {'name' => 'Others' } ] } ] } ] } ] } ] } ] } ] }; }

output:

low-199 200-499 500-899 Others

fwiw
I find that setting tabs to spaces with a tab setting of 2 can help make code a bit more readable