[ Sorry for not replying to the whole list earlier, I hope all readers
will be able to cope with fishing my reply out of the full-quotes. ]

Peter,

Here's what I came up with using the assignment variant of the
substitution operator:

> perl6-m -e 'my $text = "Well, hello!"; $text ~~ s[ <alpha>+(\W) ] = my
$res = "Rhino$0"; say (:$res); say (:$text)'
> "res" => "Rhino,"
> "text" => "Rhino, hello!"

Hope to help!
  - Timo

On 05/23/2014 03:46 AM, Peter Schwenn wrote:
> Timo,
>
> Thank you, that works very nicely.  But I'm committed to   s///;  
> instead of .subst
>
> Best I've been able to do is such as:
>
>      $text ~~ s:g/ using \s+ RMA.Rhino (\W) /{$res="using Rhino$0"}$res/;
>      say $res;
>
> which works but makes the s///; quite a bit less readable.
>
> Thank you,
>
> Peter Schwenn
>
> p.s. by the way
>      $res = ($text ~~ s:g/ using \s+ RMA.Rhino (\W) /using Rhino$0/;)
> simply sets $res to True or False as you probably knew
>
>
> On Thu, May 22, 2014 at 8:29 PM, Timo Paulssen <t...@wakelift.de
> <mailto:t...@wakelift.de>> wrote:
>
>
>     On 05/23/2014 01:57 AM, Peter Schwenn wrote:
>     > Dear Perl6-users,
>     >
>     > I'd like to print out the string value of the "replacement" after a
>     > match from a statement like:
>     >       s/pattern/replacement/;     or its .subst version.
>     >
>     > (I'm able to print out the /pattern/ (match) string simply by
>     printing
>     > $/ ).
>     >
>     > Does the /replacement/ have a name so I can print it out too.
>     >
>     > Thank you,
>
>     Hello Peter,
>
>     > perl6-m -e 'my $text = "hello world"; my $res =
>     $text.subst(/<alpha>+
>     \s+ <( <alpha>+ )>/, "heya!"); say $res.perl;'
>     > "hello heya!"
>
>     Is this at all what you're looking for?
>
>     Cheers,
>       - Timo
>
>

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to