#!perl use strict; use warnings; while () { chomp; my ($tuple, @set); print "Starting with $_\n"; while (($tuple) = /((\w)\2\2\2|(\w)(?:\3*)(?!\3)(\w)(?:\4*)(?!\4)(\w)(?:\5*)(?!\5)(\w))/) { $tuple =~ y///cs; # Only one of any character if (length($tuple) == 1) { $tuple x= 4; } print "Found $tuple!\n"; # Remove tuple for my $char (split //, $tuple) { # If it is the last of its kind, # no more matches across it are possible # I put a space in there, so it won't match \w s/(?