my @strings = qw(blah blubb hallo welt hallohallohallo hallihallo); my $re = qr{^(?:(?!hallo).)*\z}s; print "$_\n" for grep /$re/, @strings;