grep { my $pat = ( $_ eq ="" ? EMPTY_PAT : $_ ); $string =~ m/$pat/g } @patterns;