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
)
|