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/; } }