foreach my $element(@array_1) { if ($element !~ /^\s*$/) { if (($element =~ m/$output/) && ($element =~ m/$input/)) { #print out all the matching output lines