use strict; use warnings; my $str = 'AAABBCCCC'; # For str 'AAABBCCCC', I want to produce a list ('AAA', 'BB', 'CCCC'). # This works ... but is there a better way to do it? my $i = 0; # $i is used to filter out the captured $1 fields my @x = grep { ++$i % 2 } split(/(?<=(.))(?!\1)/, $str); for my $e (@x) { print "e='$e'\n" }