in reply to group things?

This is related to run length encoding. A regular expression to perform RLE is (found at http://hpaste.org/1987):
sub encode { (my $string = shift) =~s/((.)\2*)/$2 . (length $1) /eg; $string; }
Maybe you can modify this function to capture the beginning and ending positions of each run.

Update: Spoiler follows...

sub group { my $x = shift; my $pos = 0; my @groups; $x =~ s{ ((.)\2*) (?{ push(@groups, [ substr($^N,0,1), $pos, $pos+length($^N) + ]); $pos+=length($^N) }) }{}gx; \@groups; }