Front page | perl.perl6.users |
Postings from June 2019
Re: replace s///r ?
Thread Previous
|
Thread Next
From:
yary
Date:
June 11, 2019 05:54
Subject:
Re: replace s///r ?
Message ID:
CAG2CFAa=bgg2ooff3i8mQf=GZ5+=xohNMS3HQp_=8bipAjnrHQ@mail.gmail.com
p6 can transliterate from p5 rather literally
say .subst(/^/,4) for grep /^\d+$/, (325, '44a', 555, 6);
-y
-y
On Mon, Jun 10, 2019 at 9:19 PM Marc Chantreux
<marc.chantreux@renater.fr> wrote:
>
> hello people,
>
> in perl5, i can
>
> print for
> map s/^/4/r,
> grep /^\d+$/,
> <ARGV>
>
> the perl6 version is a Seq, so much more memory friendly
> but i expected (and haven't found in the documentation)
> a short equivalent of s///r so the shorter i have is:
>
> $*ARGFILES
> . lines
> . grep( / ^ <digit>+ $ / )
> . map( *.subst(/^/," * ") )
> . map(&other-things-to-do)
> . map(&say)
>
> when, of course, i want to replace
>
> . map( *.subst(/^/," * ") )
>
> by something like
>
> . map( s:r/^/* / )
>
> any idea?
>
> regards
> marc
Thread Previous
|
Thread Next