for my $inputKey (@input_array) { if (grep { $inputKey eq $_ } @input_A) ... }