my @array = ('sarah', 'john'); # stores the keys i'm interested in my %hash = ( 'sarah' => '19', 'john' => '25', 'emma' => '22', ); if (exists ($hash{$array[0]})) { print value; }