develooper Front page | perl.perl6.users | Postings from June 2019

replace s///r ?

Thread Next
From:
Marc Chantreux
Date:
June 11, 2019 04:19
Subject:
replace s///r ?
Message ID:
20190608172923.GA3372@prometheus.u-strasbg.fr
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 Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About