$s = 'abc' x 10; ## repetative test data $p = 0; ## start at offset 0 ## match against the substring starting at the offset ## and capture (3) items while( my @x = substr( $s, $p ) =~ m[(.)(.)(.)] ) { print "@x"; ## do something with the captures ## and advance the offset to the end of what was matched $p += $+[3]; } a b c a b c a b c a b c a b c a b c a b c a b c a b c a b c