Something like this (if your %customers is a HoHoH)
#!/usr/bin/perl use strict; use warnings; my %customers = ( '1' => { '127.0.0.1' => { foo => 1 }, '127.0.0.2' => { foo => 2 }, '127.0.0.3' => { foo => 3 }, }, '2' => { '127.0.0.4' => { foo => 1 }, '127.0.0.5' => { foo => 2 }, '127.0.0.6' => { foo => 3 }, }, '3' => { '127.0.0.7' => { foo => 1 }, '127.0.0.8' => { foo => 2 }, '127.0.0.9' => { foo => 3 }, }, '4' => { '127.0.0.10' => { foo => 1 }, '127.0.0.20' => { foo => 2 }, '127.0.0.30' => { foo => 3 }, } ); my @ids = qw( 1 2 3 4 ); foreach my $id ( @ids ) { foreach my $ip ( keys %{ $customers{$id} } ) { print "ID: $id, IP: $ip, fo: $customers{$id}{$ip}{foo}\n"; } }
In reply to Re: traversing through a (complex for me) data structure
by derby
in thread traversing through a (complex for me) data structure
by o2bwise
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |