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