http://www.perlmonks.org?node_id=1038857


in reply to index using a range

A bit cryptic, but without the need of $1:
my $str = '000001'; my $index = length(($str =~ /^(0*)/)[0]);
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ