OUTPUT:use v5.12; use warnings; my $h = { 'connection-id0' => { username1 => ['value 1', 'value 2'], username2 => [ 'value5' ], }, 'connection-id1' => { username1 => ['value 2', 'value 3'], }, 'connection-id2' => { username1 => ['value 3', 'value 4'], } }; while ( my ( $con, $h_users) = each %$h ){ while ( my ($user, $a_vals) = each %$h_users ) { my $val = $a_vals->[1] // ""; say "Found $con -> $user -> $val" if $val =~ /value/; } }
Found connection-id2 -> username1 -> value 4 Found connection-id1 -> username1 -> value 3 Found connection-id0 -> username1 -> value 2
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re: multiple keys hash with array as a value - loop
by LanX
in thread multiple keys hash with array as a value - loop
by grandagent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |