#!/usr/local/bin/perl @a=split(//,"1"); #easier to make test strings this way. :) for (1..10) { print "@a\n"; @b=(); $a=join("",@a); while ( $a =~ /((.)\2*/cg ) { push (@b, (length $1, $2)); } @a=@b }