in reply to perldoc of s///ee wrong or just misleading?

If hypothetically $& was assignable to, then the following are roughly equivalent:
s/X/Y/ /X/ && $& = "Y" s/X/Y/e /X/ && $& = Y s/X/Y/ee /X/ && $& = eval Y

Dave.

Replies are listed 'Best First'.
Re^2: perldoc of s///ee wrong or just misleading?
by LanX (Saint) on Dec 28, 2014 at 16:20 UTC
    I know what you mean and I agree about what is happening, but the perldoc is wrong!

    it should say

    ee Execute right side as code then eval the resulting string.

    NOT

    ee Evaluate the right side as a string then eval the result.

    see:

    lanx@lanx-1005HA:~$ perl -MO=Terse -e ' s/(x)/$1.$1/ree ' LISTOP (0x9f99668) leave [1] OP (0x9fa6040) enter COP (0x9f99688) nextstate PMOP (0x9fa2f20) subst LOGOP (0x9fa2e20) substcont UNOP (0x9fa2f00) entereval [256] # --- string eval of resu +lt UNOP (0x9fa2c58) null LISTOP (0x9fa2be8) scope # --- precompiled $1.$ +1 OP (0x9fa1b28) null [181] BINOP (0x9fa2c38) concat [3] UNOP (0x9fa2cb8) null [15] PADOP (0x9fa2d30) gvsv GV (0x9fd4c90) + *1 UNOP (0x9fa2c18) null [15] PADOP (0x9fa2c98) gvsv GV (0x9fd4c90) + *1 -e syntax OK

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

Re^2: perldoc of s///ee wrong or just misleading?
by LanX (Saint) on Dec 28, 2014 at 21:12 UTC
    > If hypothetically $& was assignable to, then the following are roughly equivalent:

    maybe better

    s/PAT/STR/ <=> m/PAT/ && $& = "STR"; s/PAT/CODE/e <=> m/PAT/ && $& = do {CODE}; s/PAT/CODE/ee <=> m/PAT/ && $& = eval do {CODE}; s/PAT/CODE/eee <=> m/PAT/ && $& = eval eval do {CODE}; ... and so on

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)