http://qs321.pair.com?node_id=515284

thor has asked for the wisdom of the Perl Monks concerning the following question:

Greetings all,

The other day, I found myself in the position to split a string not on an explicit delimiter, but rather where the string changes. A quick example might be in order:

my $x = "AAAABBBCCCCCC"; my $regex = qr(); #this is my hang-up! my @x = split($regex, $x); #I want @x = ("AAAA", "BBB", "CCCCCC")
I've gotten close. For my regex, I have thus far qr((?:(\w))(?!\1)+). This produces an array of qw(AAA A BB B CCCCCC). The problem as I see it is the following passage from perldoc -f split:
If the PATTERN contains parentheses, additional list elements are created from each matching substring in the delimiter.
However, I don't see how I can get around using capturing parentheses given that I have to use a back reference in the regular expression. Does anyone have any experience with this problem?

thor

The only easy day was yesterday