広告
引数に指定した変数に対して前回の m//g が最後にマッチした場所の次のオフセットを返します。文字列の先頭のオフセットは 0 となります。
$strx = "one two tree"; while( $strx =~ /o/g ){ print pos $strx, "\n"; }
1 7
https://www.7key.jp/program/perl/pos.html