Designation:  Non-Finmeccanica

Moritz,

Thanks for the response.  I get the same successful result as you do with:

my $line = "bar foo"; $line ~~ s/(\w+) \s+ (\w+)/$1 $0/; say $line # output:
foo bar

All well and good.  And if the pattern is one line I get success with my other 
s///; forms as well.

However I'm working with a multi-line slurped source text, and in that case 
s///; reports no error and does no substitution.

So for example if file   foobar.txt   contains these two lines:

foo bar
foo far

and is read with:

my $layn = slurp "foobar.txt";

then

$layn ~~ s:g/(\w+) \s+ (\w+)/$1 $0/; say $layn;

Makes no complaint and makes no substitution ($layn is still foo bar foo bar ). 
 (Same result for no ':g').

Perhaps Slurping is not what I should be doing -- I'm using it because great 
speed gain.

Thanks,

Peter Schwenn



-----Original Message-----
From: Moritz Lenz via RT [mailto:[email protected]]
Sent: Friday, May 02, 2014 3:51 AM
To: Schwenn, Peter
Subject: Re: [perl #121772] $x ~~ s///;

On 04/30/2014 05:21 PM, [email protected] wrote:
> # New Ticket Created by  Schwenn, Peter # Please include the string:  
> [perl #121772] # in the subject line of all future correspondence 
> about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=121772 >
>
>
> Designation: Non-Finmeccanica
> Dear Perl6'rs
>
> [In short: no variation of   $x ~~ s/...(...)../....$0..../;   seems to work 
> (to substitute any capture).]

With a current Rakudo, I cannot reproduce this:

my $line = "bar foo"; $line ~~ s/(\w+) \s+ (\w+)/$1 $0/; say $line # output:
foo bar

So either the bug has been fixed in the mean time (and a Rakudo Star release is 
upcoming today), or you need to produce a runnable piece of code (including 
example data) with which we can replicate your problem.

Cheers,
Moritz



3.3.042312

Reply via email to