Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: perldoc of s///ee wrong or just misleading?

by LanX (Saint)
on Dec 28, 2014 at 16:00 UTC ( [id://1111571]=note: print w/replies, xml ) Need Help??


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

running B::Terse shows that the RHS is even precompiled and not evaluated at runtime:

lanx@lanx-1005HA:~$ perl -MO=Terse -e 's/(x)/$1.$1/re' LISTOP (0x8eb6668) leave [1] OP (0x8ec3040) enter COP (0x8eb6688) nextstate PMOP (0x8ebff20) subst LOGOP (0x8ebff00) substcont UNOP (0x8ebfbe8) null LISTOP (0x8ebfc38) scope OP (0x8ebeb28) null [181] BINOP (0x8ebfc18) concat [3] UNOP (0x8ebfd30) null [15] PADOP (0x8ebfe20) gvsv GV (0x8ef1c90) *1 UNOP (0x8ebfc98) null [15] PADOP (0x8ebfcb8) gvsv GV (0x8ef1c90) *1

That's why this rather ill construction works

lanx@lanx-1005HA:~$ perl -e 'sub bla { s/x/BEGIN{print "compiletime\n" +}/e }' compiletime

But still doesn't make the perldocs clearer...

Cheers Rolf

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1111571]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found