for my $i (0..length($string)-1) { # whatever with substr($string, $i, 1) } #### while ($string =~ /./gs) { # whatever with $& # note that this incurs the penalty for using $& }