sub regindex { my ($str, $rx, $pos) = @_; pos($str) = $pos || 0; $str =~ /$rx/g or return -1; return $-[0]; }