Hi

according to perlop#s/PATTERN/REPLACEMENT/ a double eval isn't a double eval but the eval of an interpolation

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

At least that's how I understand the distinction between "evaluate as an expression" and "evaluate as a string"...

Problem is that I can't see this distinction, ee produces just

eval ( eval 'RHS' )

eval do { RHS } ¹

for me and not

eval "RHS".

Or what is meant here, if "evaluate as a string" isn't supposed to mean "string resp. var interpolation", what else?

some snippets as demonstration

DB<135> $_='x' => "x" DB<136> $a='$b'; $b="B" => "B" DB<137> s/x/$a.$a/r # -> "$a.$a" (interpolation) => "\$b.\$b" DB<138> s/x/$a.$a/re # -> eval '$a.$a' => "\$b\$b" DB<139> s/x/$a.$a/ree # -> eval "\$b\$b" not eval "\$b.\$b" Scalar found where operator expected at (eval 106)[(eval 105)[multi_pe +rl5db.pl:644]:2] line 1, near "$b$b" ...

but

DB<140> s/x/$a.'.'.$a/ree # -> eval "\$b.\$b" => "BB" DB<141> s/x/$a.'.'.$a/re # -> eval '$a.\'.\'.$a' => "\$b.\$b" DB<142> s/x/$a.'.'.$a/r # -> "$a.'.'.$a" => "\$b.'.'.\$b" DB<143> eval "\$b.'.'.\$b" # what perldoc predicts for line 140 => "B.B"

Cheers Rolf

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

¹) updated: the RHS is precompiled, but eval 'RHS' means runtime compilation


In reply to 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.