$regexp="a{2}"; $_="aaaa"; do { push @a, $1 if ( m/^($regexp)/ ) } while ( s/^.// ) ; print join ( "-", @a );