#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11137799 use warnings; $_='ZBBBCZZ'; my @list = split ' ', s/(.)\K(?!\1)/ /gr; use Data::Dump 'dd'; dd "given $_ got", \@list; #### ("given ZBBBCZZ got", ["Z", "BBB", "C", "ZZ"])