Yes! This is exactly the thing i talk about, pos() for next iteration of regexp is not changes. And looks like there is no way to change it, and this is realy meaningless because variable regexp save initial value of variable and use this value for search and another for replace results.
$ perl -MDevel::Peek -e "\$_='qwerty';Dump(\$_);s/[rt]/Dump(\$_);/ge; +print Dump(\$_)" SV = PV(0x801838) at 0x82fde0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x201fe0 "qwerty"\0 CUR = 6 LEN = 8 SV = PVMG(0x823514) at 0x82fde0 REFCNT = 1 FLAGS = (SMG,POK,pPOK) IV = 0 NV = 0 PV = 0x201fe0 "qwerty"\0 CUR = 6 LEN = 8 MAGIC = 0x2018d0 MG_VIRTUAL = &PL_vtbl_mglob MG_TYPE = PERL_MAGIC_regex_global(g) MG_LEN = 3 SV = PVMG(0x823514) at 0x82fde0 REFCNT = 1 FLAGS = (SMG,POK,pPOK) IV = 0 NV = 0 PV = 0x201fe0 "qwerty"\0 CUR = 6 LEN = 8 MAGIC = 0x2018d0 MG_VIRTUAL = &PL_vtbl_mglob MG_TYPE = PERL_MAGIC_regex_global(g) MG_LEN = 4 SV = PVMG(0x823514) at 0x82fde0 REFCNT = 1 FLAGS = (SMG,POK,pPOK) IV = 0 NV = 0 PV = 0x2010d0 "qwey"\0 CUR = 4 LEN = 8 MAGIC = 0x2018d0 MG_VIRTUAL = &PL_vtbl_mglob MG_TYPE = PERL_MAGIC_regex_global(g) MG_LEN = -1
So, it seems my task can't be solved by using follow construction
$data =~s/([^\n]{16})/pos($data)=0;ch($1)/ge;
(Note: escaping of $ simbol is nessesary for bash
# perl -e "\$_='qwerty';s/r/print pos();/e;" 3 BUT # perl -e "$_='qwerty';s/r/print pos();/e;" syntax error at -e line 1, near ";=" Execution of -e aborted due to compilation errors. # uname -v Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1 +504.7.4~1/RELEASE_I386
)

In reply to Re^8: Using pos() inside regexp (no /e) by braveghost
in thread Using pos() inside regexp by braveghost

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.