Author: moritz Date: 2010-01-04 11:49:21 +0100 (Mon, 04 Jan 2010) New Revision: 29454
Modified: docs/Perl6/Spec/S05-regex.pod Log: [S05] small clarification for .match and .subst Modified: docs/Perl6/Spec/S05-regex.pod =================================================================== --- docs/Perl6/Spec/S05-regex.pod 2010-01-04 10:47:13 UTC (rev 29453) +++ docs/Perl6/Spec/S05-regex.pod 2010-01-04 10:49:21 UTC (rev 29454) @@ -3948,6 +3948,15 @@ $str.=subst(/pat/, "replacement"); $str.=subst(/pat/, {"replacement"}); +The C<.match> and C<.subst> methods support the adverbs of C<m//> and +C<s///> as named arguments, so you can write + + $str.match(/pat/, :g) + +as an equivalent to + + $str.comb(/pat/, :match) + There is no syntactic sugar here, so in order to get deferred evaluation of the replacement you must put it into a closure. The syntactic sugar is provided only by the quotelike forms. First there @@ -3988,7 +3997,7 @@ into something like: - $target.subst(rx:g[pattern], { $() op expr }) + $target.subst(rx[pattern], { $() op expr }, :g) So, for example, you can multiply every dollar amount by 2 with: