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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.