in reply to index using a range
A good application for the under-estimated comma operator:
$str = "000001"; $index = ( $str =~ /^(0*)/, length $1 ); print "$index\n"; [download]