use warnings; $str = 'ABC'; print pos($str); # pos($str) = 1; while ($str=~/.\G/g) { print $&; }