#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; $hash{test001}=['NAME11', 'NAM13']; $hash{test002}=['Name12']; my @array = qw(NAME13 NAME14 NAME15); for my $key(keys %hash){ if(grep{my $i = $_; defined $i and grep{$_ eq $i}@array}@{$hash{$key}}){ print Dumper($hash{$key}); } }