~$ perl -e '$_="qwerty"; s/r/print pos(). "\n";/e; print $_;' 3 qwe1ty