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


In reply to Re: perldoc of s///ee wrong or just misleading? by LanX
in thread perldoc of s///ee wrong or just misleading? by LanX

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.