for my $index ( 0 .. length( $string ) - 1 ) { my $a = index( $string, $index, 1 ); # # do something }