foreach my $element (grep { /$output/ && /$input/ } @array_1) {