$ perl -Mstrict -Mwarnings -E ' my $str = q{abc} x 3; for ( my $idx = 0; $idx < length $str; $idx += 3 ) { my $three = substr $str, $idx - 1, 3; say $three; }' c cab cab $