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

Yes the wording is odd, but like a lot of perl docs, if you keep reading you will get all the details, like: A second e modifier will cause the replacement portion to be evaled before being run as a Perl expression.

I once wrote

s/regex/STRING /e
means replace that matched by regex with string
s/regex/CODEHERE/e
means replace that matched by regex with result of code; the e in s///e tells the s///ubstitution operator that the s//CODEHERE/e is code and not a string
s/regex/CODEHERE/e
means treat CODEHERE string as code
s/regex/CODEHERE/ee
means treat CODEHERE string as code, and treat the return value of that code as code
s/regex/CODEHERE/ee
means s/regex/eval CODEHERE/e

One time I even tried to explain this way :)

my $string = 'string'; ## s/string/replacement/; $string->substitute( 'pattern', 'replacement' ); ## s/string/codehere/e; $string->substitute( 'pattern', sub { ... } ); ## s/string/codehere/ee; $string->substitute( 'pattern', sub { eval ... } ); ## s/string/codehere/eee; $string->substitute( 'pattern', sub { eval eval ... } );

Replies are listed 'Best First'.
Re^2: perldoc of s///ee wrong or just misleading? (read more)
by ikegami (Patriarch) on Dec 29, 2014 at 18:05 UTC

    Consider

    s/.../$1' $2"/

    More accurate:

    $string->substitute( qr/pattern/, sub { qq/replacement/ } );