for my $i (0..length($string)-1) { # whatever with substr($string, $i, 1) }