my $string = 'aaabbcddeef'; while($string =~ m/\w(?!patternthatworkd)/gi) { do stuff.... }