$VAR1 = { 'connection-id' => { 'username' => [ value 1, value 2 ], } .... } #### foreach my $connection (keys %h) { foreach my $userid (keys %{$h{$connection}}) { @a_ref = @{$h{$connection}{$userid}}; if(lc($userid) eq "rmdb_dbo") { print @a_ref, if ( $a_ref[1] =~ m/update\s*[table\s*]rmdb_dbo./i ); } } }