Re: run on regex line?

[email protected] (William Michels via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
Just want to elaborate on the two different ways of combining statements mentioned earlier.


1A.  If you're using `-pe` command line flags, you use `s///` and combine statements with `;` semicolon:

~$ echo 'roses are red' | raku -pe 's/roses/lilacs/;  s/red/blue/'
lilacs are blue

1B.  Using `-pe` with `s///` but `andthen` instead of `;` is apparently a mistake--you don't get what you expect:

~$ echo 'roses are red' | raku -pe 's/roses/lilacs/ andthen s/red/blue/'
lilacs are red


2A.  Conversely, if you're using `-ne` command line flags, you use `S///` and combine statements with `andthen`:

~$ echo 'roses are red' | raku -ne 'S/roses/lilacs/ andthen S/red/blue/.put'
lilacs are blue

2B.  Again, using `-ne` with `S///` but `;` instead of `andthen` is apparently a mistake--you don't get what you expect:

~$ echo 'roses are red' | raku -ne 'S/roses/lilacs/;  S/red/blue/.put'
roses are blue


HTH, Bill.


> On Jan 20, 2024, at 04:20, Richard Hainsworth <[email protected]> wrote:
> Todd,
> You could use Elizabeth Mattijsen's App-rak. It's a Raku utility that does grep, sed, awk.
> Richard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.