Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #224887 > unrolled thread
| Started by | William Michels <wjm1@caa.columbia.edu> |
|---|---|
| First post | 2020-07-16 21:10 +0200 |
| Last post | 2020-07-17 14:40 +0200 |
| Articles | 6 — 4 participants |
Back to article view | Back to linux.debian.user
Re: delimiters with more than one character? William Michels <wjm1@caa.columbia.edu> - 2020-07-16 21:10 +0200
Re: delimiters with more than one character? Nicolas George <george@nsup.org> - 2020-07-16 21:10 +0200
Re: delimiters with more than one character? William Michels <wjm1@caa.columbia.edu> - 2020-07-17 04:10 +0200
Re: delimiters with more than one character? Dan Ritter <dsr@randomstring.org> - 2020-07-16 21:30 +0200
Re: delimiters with more than one character? David Wright <deblis@lionunicorn.co.uk> - 2020-07-17 05:00 +0200
Re: delimiters with more than one character? Dan Ritter <dsr@randomstring.org> - 2020-07-17 14:40 +0200
| From | William Michels <wjm1@caa.columbia.edu> |
|---|---|
| Date | 2020-07-16 21:10 +0200 |
| Subject | Re: delimiters with more than one character? |
| Message-ID | <Athqx-2eq-9@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
<a href="mailto:debian-user@lists.debian.org?in-reply-to=<
CAFakBwhN7crFsov60mR9tF4VUS1Duv4CNQohBBDyX-AWOXW-Kw@mail.gmail.com>&subject=Re:%20Re:
delimiters with more than one character? ...">debian-user@lists.debian.org
</a>
I've slowly been learning the Raku programming language (AKA Perl6), and
while I'm far from being an expert, this is the first solution I came up
with (raku one-or-two-liners, at the bash command prompt):
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
$s.put';
34 + 45 | abc | 1 2 3 | c|123abc
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
$s.split("|").raku.put';
(" 34 + 45 ", " abc ", " 1 2 3 ", " c", "123abc ").Seq
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
.put for $s.split("|");'
34 + 45
abc
1 2 3
c
123abc
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
.raku.put for $s.split("|");'
" 34 + 45 "
" abc "
" 1 2 3 "
" c"
"123abc "
user@mbook:~$
Looking at the Str typed-variable $s I see that backslash escapes are
removed automatically (the second command only has to split on the pipe
character). So maybe this isn't a general solution, but it works for the
example given.
https://raku.org/
HTH, Bill.
(Apologies if this message gets threaded improperly).
[toc] | [next] | [standalone]
| From | Nicolas George <george@nsup.org> |
|---|---|
| Date | 2020-07-16 21:10 +0200 |
| Message-ID | <Athqy-2eq-19@gated-at.bofh.it> |
| In reply to | #224887 |
[Multipart message — attachments visible in raw view] — view raw
William Michels (12020-07-16): > <a href="mailto:debian-user@lists.debian.org?in-reply-to=< > CAFakBwhN7crFsov60mR9tF4VUS1Duv4CNQohBBDyX-AWOXW-Kw@mail.gmail.com>&subject=Re:%20Re: > delimiters with more than one character? ...">debian-user@lists.debian.org > </a> ??? > I've slowly been learning the Raku programming language (AKA Perl6), and > while I'm far from being an expert, this is the first solution I came up > with (raku one-or-two-liners, at the bash command prompt): > > user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc "; > $s.put'; > 34 + 45 | abc | 1 2 3 | c|123abc Observe your output carefully. You'll notice that the string you defined does not actually contain any backslash. Regards, -- Nicolas George
[toc] | [prev] | [next] | [standalone]
| From | William Michels <wjm1@caa.columbia.edu> |
|---|---|
| Date | 2020-07-17 04:10 +0200 |
| Message-ID | <AtnYZ-6Zc-1@gated-at.bofh.it> |
| In reply to | #224888 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Jul 16, 2020 at 12:03 PM Nicolas George wrote: > > Observe your output carefully. You'll notice that the string you defined > does not actually contain any backslash. > > Regards, > > Nicolas George Thank you, Nicholas! Looks like the trick for Raku one-liners on the bash command line is to use single quotes on the outside, and one of Raku's quoting-language constructs (Q[ ... ], known as the Raku 'literal string' construct) on the inside. Note splitting on the two-character "\|" delimiter in the second (final) statement: user@mbook:~$ raku -e 'my Str $s= Q[ 34 + 45 \| abc \| 1 2 3 \| c\|123abc ]; .raku.put for $s.split( Q[\|] );' " 34 + 45 " " abc " " 1 2 3 " " c" "123abc " user@mbook:~$ Reference: "The Q Lang" https://docs.raku.org/language/quoting HTH, Bill.
[toc] | [prev] | [next] | [standalone]
| From | Dan Ritter <dsr@randomstring.org> |
|---|---|
| Date | 2020-07-16 21:30 +0200 |
| Message-ID | <AthJT-2kF-7@gated-at.bofh.it> |
| In reply to | #224887 |
William Michels wrote: > <a href="mailto:debian-user@lists.debian.org?in-reply-to=< > CAFakBwhN7crFsov60mR9tF4VUS1Duv4CNQohBBDyX-AWOXW-Kw@mail.gmail.com>&subject=Re:%20Re: > delimiters with more than one character? ...">debian-user@lists.debian.org > </a> > > I've slowly been learning the Raku programming language (AKA Perl6), and Please don't call it that. Perl 1-5 have a clear relationship, and that relationship continues in Perl 7 and subsequent versions. Raku should not be referred to as a Perl, even though it was for many years. Raku is a new lineage. -dsr-
[toc] | [prev] | [next] | [standalone]
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Date | 2020-07-17 05:00 +0200 |
| Message-ID | <AtoLn-7lv-1@gated-at.bofh.it> |
| In reply to | #224889 |
On Thu 16 Jul 2020 at 15:27:06 (-0400), Dan Ritter wrote: > William Michels wrote: > > I've slowly been learning the Raku programming language (AKA Perl6), and > > Please don't call it that. Perl 1-5 have a clear relationship, and that > relationship continues in Perl 7 and subsequent versions. Raku should > not be referred to as a Perl, even though it was for many years. > > Raku is a new lineage. Thank you, William. I would not have known what you were talking about without the AKA. Surely we're not obliged to write "the language formerly known as Perl6". IIUC the name Raku isn't yet a year old. I lost interest in Perl around the time of Perl4→5, so I had no idea that that's what became of Perl6. I remember it being talked about when I retired, and stopped reading the computing press. I guess Perl7 is at about the same stage, still over the horizon. Cheers, David.
[toc] | [prev] | [next] | [standalone]
| From | Dan Ritter <dsr@randomstring.org> |
|---|---|
| Date | 2020-07-17 14:40 +0200 |
| Message-ID | <AtxOF-4wD-11@gated-at.bofh.it> |
| In reply to | #224893 |
David Wright wrote: > On Thu 16 Jul 2020 at 15:27:06 (-0400), Dan Ritter wrote: > > William Michels wrote: > > > I've slowly been learning the Raku programming language (AKA Perl6), and > > > > Please don't call it that. Perl 1-5 have a clear relationship, and that > > relationship continues in Perl 7 and subsequent versions. Raku should > > not be referred to as a Perl, even though it was for many years. > > > > Raku is a new lineage. > > Thank you, William. I would not have known what you were talking about > without the AKA. Surely we're not obliged to write "the language > formerly known as Perl6". IIUC the name Raku isn't yet a year old. > > I lost interest in Perl around the time of Perl4???5, so I had no idea > that that's what became of Perl6. I remember it being talked about > when I retired, and stopped reading the computing press. I guess > Perl7 is at about the same stage, still over the horizon. https://www.perl.com/article/announcing-perl-7 "Perl 7.0 is going to be v5.32 but with different, saner, more modern defaults. You won't have to enable most of the things you are already doing because they are enabled for you. The major version jump sets the boundary between how we have been doing things and what we can do in the future." -dsr-
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web