my %b_value; @b_value{@b_array}=(); my @c_array = grep exists $b_value{$_}, @a_array;