For example
gives you a good indication of what the question is and what sort of answer you can expect.next unless $item->{is_a_switch};
As has been pointed out, with this approach you are more than halfway to having an object.
output#!/usr/local/bin/perl use strict; use warnings; my %network = get_network(); for my $blade (keys %network){ for my $item (@{$network{$blade}}){ next unless $item->{is_a_switch}; print qq{$item->{item_name}\n}; for my $kit (@{$item->{more_kit}}){ print qq{ kit: $kit->{kit_name}\n}; } } } sub get_network { my %network = ( 01/01 => [ { is_a_switch => 0, item_name => q{router}, more_kit => 0, }, { is_a_switch => 1, item_name => q{hpswitch1}, more_kit => [ { port => q{port1}, kit_name => q{workstation1}, }, { port => q{port2}, kit_name => q{workstation2}, }, ], } ], 01/02 => [ { is_a_switch => 1, item_name => q{hpswitch2}, more_kit => [ { port => q{port1}, kit_name => q{server4}, }, { port => q{port2}, kit_name => q{server5}, }, ], } ], 01/03 => [ { is_a_switch => 0, item_name => q{server2}, more_kit => 0, }, ], ); return %network; }
hpswitch1 kit: workstation1 kit: workstation2 hpswitch2 kit: server4 kit: server5
In reply to Re: generating hashes of hashes
by wfsp
in thread generating hashes of hashes
by mrnick1234567
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |