From: Gurusamy Sarathy Date: Sun, 19 Mar 2000 06:18:24 +0000 (+0000) Subject: better notes on s///ee (from Simon Cozens ) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cec88af6de547f81fd0f3124a07cfda36f778c89;p=p5sagit%2Fp5-mst-13.2.git better notes on s///ee (from Simon Cozens ) p4raw-id: //depot/perl@5817 --- diff --git a/pod/perlop.pod b/pod/perlop.pod index db0563c..ce6fb66 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -1140,9 +1140,10 @@ text is not evaluated as a command. If the PATTERN is delimited by bracketing quotes, the REPLACEMENT has its own pair of quotes, which may or may not be bracketing quotes, e.g., C or C<< s/bar/ >>. A C will cause the -replacement portion to be interpreted as a full-fledged Perl expression -and eval()ed right then and there. It is, however, syntax checked at -compile-time. +replacement portion to be treated as a full-fledged Perl expression +and evaluated right then and there. It is, however, syntax checked at +compile-time. A second C modifier will cause the replacement portion +to be Ced before being run as a Perl expression. Examples: @@ -1169,8 +1170,12 @@ Examples: # symbolic dereferencing s/\$(\w+)/${$1}/g; - # /e's can even nest; this will expand - # any embedded scalar variable (including lexicals) in $_ + # Add one to the value of any numbers in the string + s/(\d+)/1 + $1/eg; + + # This will expand any embedded scalar variable + # (including lexicals) in $_ : First $1 is interpolated + # to the variable name, and then evaluated s/(\$\w+)/$1/eeg; # Delete (most) C comments.