String to array problem

Hi All,

I have been scratching my head trying to figure out
how to turn a string with quotes in it into an array.

my $x='ls -al "Program Files" "Moe Curly Larry"';

Desired result:
my @y;
    $y[0] = 'ls';
    $y[1] = '-la';
    $y[2] = 'Program Files';
    $y[3] = 'Moe Curly Larry';

Any words of wisdom?

Many thanks,
-T
0
ToddAndMargo
7/16/2017 11:41:07 PM
perl.perl6.users 836 articles. 0 followers. Follow

20 Replies
34 Views

Similar Articles

[PageSpeed] 27

--94eb2c0406028e114d055477e691
Content-Type: text/plain; charset="UTF-8"

On Sun, Jul 16, 2017 at 7:41 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> my $x='ls -al "Program Files" "Moe Curly Larry"';
>
> Desired result:
> my @y;
>    $y[0] = 'ls';
>    $y[1] = '-la';
>    $y[2] = 'Program Files';
>    $y[3] = 'Moe Curly Larry';
>

This was just discussed a few days ago, under the subject "Is there a
bash/shlex-like processor with double-quotes handling?"

http://www.mail-archive.com/perl6-users@perl.org/msg03986.html

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--94eb2c0406028e114d055477e691
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
un, Jul 16, 2017 at 7:41 PM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"=
mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">my $x=
=3D&#39;ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;&#39;;<=
br>
<br>
Desired result:<br>
my @y;<br>
=C2=A0 =C2=A0$y[0] =3D &#39;ls&#39;;<br>
=C2=A0 =C2=A0$y[1] =3D &#39;-la&#39;;<br>
=C2=A0 =C2=A0$y[2] =3D &#39;Program Files&#39;;<br>
=C2=A0 =C2=A0$y[3] =3D &#39;Moe Curly Larry&#39;;<br></blockquote><div><br>=
</div><div>This was just discussed a few days ago, under the subject=C2=A0&=
quot;Is there a bash/shlex-like processor with double-quotes handling?&quot=
;</div><div>=C2=A0</div></div><a href=3D"http://www.mail-archive.com/perl6-=
users@perl.org/msg03986.html">http://www.mail-archive.com/perl6-users@perl.=
org/msg03986.html</a><br clear=3D"all"><div><br></div>-- <br><div class=3D"=
gmail_signature"><div dir=3D"ltr"><div>brandon s allbery kf8nh =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 sine nomine associates</div><div><a href=3D"mailto:all=
bery.b@gmail.com" target=3D"_blank">allbery.b@gmail.com</a> =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"mailto:ballbery@sinenomine.net" t=
arget=3D"_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerbe=
ros, infrastructure, xmonad =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://si=
nenomine.net" target=3D"_blank">http://sinenomine.net</a></div></div></div>
</div></div>

--94eb2c0406028e114d055477e691--
0
allbery
7/16/2017 11:47:08 PM
VCwNCg0KbXkgJHggPSAnbHMgLWFsICJQcm9ncmFtIEZpbGVzIiAiTW9lIEN1cmx5IExhcnJ5Iic7
DQpteSBAeSA9IH4oJHggfn4gbTpnbG9iYWwvIFsgJyInIDwtWyAiIF0+ICogJyInIHwgXFMrIF0g
Lyk7DQoNCk1hcmsgRGV2aW5lDQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiBU
b2RkQW5kTWFyZ28gW21haWx0bzpUb2RkQW5kTWFyZ29Aem9oby5jb21dIA0KU2VudDogU3VuZGF5
LCBKdWx5IDE2LCAyMDE3IDc6NDEgUE0NClRvOiBwZXJsNi11c2VycyA8cGVybDYtdXNlcnNAcGVy
bC5vcmc+DQpTdWJqZWN0OiBTdHJpbmcgdG8gYXJyYXkgcHJvYmxlbQ0KDQpIaSBBbGwsDQoNCkkg
aGF2ZSBiZWVuIHNjcmF0Y2hpbmcgbXkgaGVhZCB0cnlpbmcgdG8gZmlndXJlIG91dCBob3cgdG8g
dHVybiBhIHN0cmluZyB3aXRoIHF1b3RlcyBpbiBpdCBpbnRvIGFuIGFycmF5Lg0KDQpteSAkeD0n
bHMgLWFsICJQcm9ncmFtIEZpbGVzIiAiTW9lIEN1cmx5IExhcnJ5Iic7DQoNCkRlc2lyZWQgcmVz
dWx0Og0KbXkgQHk7DQogICAgJHlbMF0gPSAnbHMnOw0KICAgICR5WzFdID0gJy1sYSc7DQogICAg
JHlbMl0gPSAnUHJvZ3JhbSBGaWxlcyc7DQogICAgJHlbM10gPSAnTW9lIEN1cmx5IExhcnJ5JzsN
Cg0KQW55IHdvcmRzIG9mIHdpc2RvbT8NCg0KTWFueSB0aGFua3MsDQotVA0K
0
mark
7/17/2017 12:16:32 AM
> -----Original Message-----
> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
> Sent: Sunday, July 16, 2017 7:41 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: String to array problem
> 
> Hi All,
> 
> I have been scratching my head trying to figure out how to turn a string with quotes in it into an array.
> 
> my $x='ls -al "Program Files" "Moe Curly Larry"';
> 
> Desired result:
> my @y;
>      $y[0] = 'ls';
>      $y[1] = '-la';
>      $y[2] = 'Program Files';
>      $y[3] = 'Moe Curly Larry';
> 
> Any words of wisdom?
> 
> Many thanks,
> -T
> 


On 07/16/2017 05:16 PM, Mark Devine wrote:
 > T,
 >
 > my $x = 'ls -al "Program Files" "Moe Curly Larry"';
 > my @y = ~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
 >
 > Mark Devine
 >

Thank you!

May I impose on you to take apart the example
and explain what each part is doing?



-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
ToddAndMargo
7/17/2017 12:26:08 AM
On 07/16/2017 05:16 PM, Mark Devine wrote:
> T,
> 
> my $x = 'ls -al "Program Files" "Moe Curly Larry"';
> my @y = ~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
> 
> Mark Devine
> 
> -----Original Message-----
> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
> Sent: Sunday, July 16, 2017 7:41 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: String to array problem
> 
> Hi All,
> 
> I have been scratching my head trying to figure out how to turn a string with quotes in it into an array.
> 
> my $x='ls -al "Program Files" "Moe Curly Larry"';
> 
> Desired result:
> my @y;
>      $y[0] = 'ls';
>      $y[1] = '-la';
>      $y[2] = 'Program Files';
>      $y[3] = 'Moe Curly Larry';
> 
> Any words of wisdom?
> 
> Many thanks,
> -T
> 


It kinda, sorta doesn't work:

<code>
$ cat ./QuoteArrayTest.pl6
#! /usr/bin/env perl6

use strict;

print "\n";
my $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"';
my @y =~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
say "$x\n\@y:";

for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; }
print "\n";
</code>

ls -al \"Program Files\" \"Moe Curly Larry\"
@y:
$y[0] = <ls -al \"Program Files\" \"Moe Curly Larry\">


What did I do wrong?


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
ToddAndMargo
7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zIC1hbCBcIlByb2dyYW0gRmlsZXNcIiBcIk1vZSBDdXJseSBM
YXJyeVwiPg0KDQoNCldoYXQgZGlkIEkgZG8gd3Jvbmc/DQoNCg0KLS0NCn5+fn5+fn5+fn5+fn5+
fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+DQpDb21wdXRlcnMgYXJlIGxpa2UgYWlyIGNvbmRpdGlv
bmVycy4NClRoZXkgbWFsZnVuY3Rpb24gd2hlbiB5b3Ugb3BlbiB3aW5kb3dzDQp+fn5+fn5+fn5+
fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fg0K
0
mark
7/17/2017 12:53:59 AM
> -----Original Message-----
> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
> Sent: Sunday, July 16, 2017 8:35 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: Re: String to array problem
> 
> On 07/16/2017 05:16 PM, Mark Devine wrote:
>> T,
>>
>> my $x = 'ls -al "Program Files" "Moe Curly Larry"'; my @y = ~($x ~~
>> m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
>>
>> Mark Devine
>>
>> -----Original Message-----
>> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
>> Sent: Sunday, July 16, 2017 7:41 PM
>> To: perl6-users <perl6-users@perl.org>
>> Subject: String to array problem
>>
>> Hi All,
>>
>> I have been scratching my head trying to figure out how to turn a string with quotes in it into an array.
>>
>> my $x='ls -al "Program Files" "Moe Curly Larry"';
>>
>> Desired result:
>> my @y;
>>       $y[0] = 'ls';
>>       $y[1] = '-la';
>>       $y[2] = 'Program Files';
>>       $y[3] = 'Moe Curly Larry';
>>
>> Any words of wisdom?
>>
>> Many thanks,
>> -T
>>
> 
> 
> It kinda, sorta doesn't work:
> 
> <code>
> $ cat ./QuoteArrayTest.pl6
> #! /usr/bin/env perl6
> 
> use strict;
> 
> print "\n";
> my $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"'; my @y =~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /); say "$x\n\@y:";
> 
> for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; } print "\n"; </code>
> 
> ls -al \"Program Files\" \"Moe Curly Larry\"
> @y:
> $y[0] = <ls -al \"Program Files\" \"Moe Curly Larry\">
> 
> 
> What did I do wrong?


On 07/16/2017 05:50 PM, Mark Devine wrote:
 > T,
 >
 > Sorry (newbie, remember).  For the first question that did not have 
backslash double-quotes:
 >
 > my ($x, @y);
 > $x = 'ls -al "Program Files" "Moe Curly Larry"';
 > @y = $x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /;
 > for @y -> $match { say ~$match; }
 >
 > Don't know about the second question with backslash double-quotes.
 >
 > Mark


That worked.  Thank you!

<code>
#! /usr/bin/env perl6

use strict;

print "\n";
my $x = 'ls -al "Program Files" "Moe Curly Larry"';
my @y = $x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /;
say "$x\n\@y:";

for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; }
print "\n";
</code>


$./QuoteArrayTest.pl6

ls -al "Program Files" "Moe Curly Larry"
@y:
$y[0] = <ls>
$y[1] = <-al>
$y[2] = <"Program Files">
$y[3] = <"Moe Curly Larry">
0
ToddAndMargo
7/17/2017 12:54:56 AM
> -----Original Message-----
> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
> Sent: Sunday, July 16, 2017 8:35 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: Re: String to array problem
> 
> On 07/16/2017 05:16 PM, Mark Devine wrote:
>> T,
>>
>> my $x = 'ls -al "Program Files" "Moe Curly Larry"'; my @y = ~($x ~~
>> m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
>>
>> Mark Devine
>>
>> -----Original Message-----
>> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
>> Sent: Sunday, July 16, 2017 7:41 PM
>> To: perl6-users <perl6-users@perl.org>
>> Subject: String to array problem
>>
>> Hi All,
>>
>> I have been scratching my head trying to figure out how to turn a string with quotes in it into an array.
>>
>> my $x='ls -al "Program Files" "Moe Curly Larry"';
>>
>> Desired result:
>> my @y;
>>       $y[0] = 'ls';
>>       $y[1] = '-la';
>>       $y[2] = 'Program Files';
>>       $y[3] = 'Moe Curly Larry';
>>
>> Any words of wisdom?
>>
>> Many thanks,
>> -T
>>
> 
> 
> It kinda, sorta doesn't work:
> 
> <code>
> $ cat ./QuoteArrayTest.pl6
> #! /usr/bin/env perl6
> 
> use strict;
> 
> print "\n";
> my $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"'; my @y =~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /); say "$x\n\@y:";
> 
> for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; } print "\n"; </code>
> 
> ls -al \"Program Files\" \"Moe Curly Larry\"
> @y:
> $y[0] = <ls -al \"Program Files\" \"Moe Curly Larry\">
> 
> 
> What did I do wrong?


On 07/16/2017 05:53 PM, Mark Devine wrote:
 > T,
 >
 > This regex seems to work in both cases:	m:global/ [ \\? '"' <-[ " ]> 
* \\? '"' | \S+ ] /;
 >
 > #!/usr/bin/env perl6
 > use v6;
 >
 > my ($x, @y);
 >
 > $x = 'ls -al "Program Files" "Moe Curly Larry"';
 > @y = $x ~~ m:global/ [ \\? '"' <-[ " ]> * \\? '"' | \S+ ] /;
 > for @y -> $match { say ~$match; }
 >
 > $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"';
 > @y = $x ~~ m:global/ [ \\? '"' <-[ " ]> * \\? '"' | \S+ ] /;
 > for @y -> $match { say ~$match; }
 >
 > Mark
 >


Brain teaser.  Thank you again!
0
ToddAndMargo
7/17/2017 12:56:54 AM
--001a114260f004226d055478e340
Content-Type: text/plain; charset="UTF-8"

Nested quotes and escapes are handled by the Grammar-based solution I
pointed to. You can't handle them in general with a simple regex.

On Sun, Jul 16, 2017 at 8:54 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

>
> -----Original Message-----
>> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
>> Sent: Sunday, July 16, 2017 8:35 PM
>> To: perl6-users <perl6-users@perl.org>
>> Subject: Re: String to array problem
>>
>> On 07/16/2017 05:16 PM, Mark Devine wrote:
>>
>>> T,
>>>
>>> my $x = 'ls -al "Program Files" "Moe Curly Larry"'; my @y = ~($x ~~
>>> m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
>>>
>>> Mark Devine
>>>
>>> -----Original Message-----
>>> From: ToddAndMargo [mailto:ToddAndMargo@zoho.com]
>>> Sent: Sunday, July 16, 2017 7:41 PM
>>> To: perl6-users <perl6-users@perl.org>
>>> Subject: String to array problem
>>>
>>> Hi All,
>>>
>>> I have been scratching my head trying to figure out how to turn a string
>>> with quotes in it into an array.
>>>
>>> my $x='ls -al "Program Files" "Moe Curly Larry"';
>>>
>>> Desired result:
>>> my @y;
>>>       $y[0] = 'ls';
>>>       $y[1] = '-la';
>>>       $y[2] = 'Program Files';
>>>       $y[3] = 'Moe Curly Larry';
>>>
>>> Any words of wisdom?
>>>
>>> Many thanks,
>>> -T
>>>
>>>
>>
>> It kinda, sorta doesn't work:
>>
>> <code>
>> $ cat ./QuoteArrayTest.pl6
>> #! /usr/bin/env perl6
>>
>> use strict;
>>
>> print "\n";
>> my $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"'; my @y =~($x ~~
>> m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /); say "$x\n\@y:";
>>
>> for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; } print "\n";
>> </code>
>>
>> ls -al \"Program Files\" \"Moe Curly Larry\"
>> @y:
>> $y[0] = <ls -al \"Program Files\" \"Moe Curly Larry\">
>>
>>
>> What did I do wrong?
>>
>
>
> On 07/16/2017 05:50 PM, Mark Devine wrote:
> > T,
> >
> > Sorry (newbie, remember).  For the first question that did not have
> backslash double-quotes:
> >
> > my ($x, @y);
> > $x = 'ls -al "Program Files" "Moe Curly Larry"';
> > @y = $x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /;
> > for @y -> $match { say ~$match; }
> >
> > Don't know about the second question with backslash double-quotes.
> >
> > Mark
>
>
> That worked.  Thank you!
>
> <code>
> #! /usr/bin/env perl6
>
> use strict;
>
> print "\n";
> my $x = 'ls -al "Program Files" "Moe Curly Larry"';
> my @y = $x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /;
> say "$x\n\@y:";
>
> for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; }
> print "\n";
> </code>
>
>
> $./QuoteArrayTest.pl6
>
> ls -al "Program Files" "Moe Curly Larry"
> @y:
> $y[0] = <ls>
> $y[1] = <-al>
>
> $y[2] = <"Program Files">
> $y[3] = <"Moe Curly Larry">
>



-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--001a114260f004226d055478e340
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Nested quotes and escapes are handled by the Grammar-based=
 solution I pointed to. You can&#39;t handle them in general with a simple =
regex.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Su=
n, Jul 16, 2017 at 8:54 PM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt=
;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><span class=3D"">
-----Original Message-----<br>
From: ToddAndMargo [mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=
=3D"_blank">ToddAndMargo@zoho.com</a>]<br></span><span class=3D"">
Sent: Sunday, July 16, 2017 8:35 PM<br>
To: perl6-users &lt;<a href=3D"mailto:perl6-users@perl.org" target=3D"_blan=
k">perl6-users@perl.org</a>&gt;<br></span><div><div class=3D"h5">
Subject: Re: String to array problem<br>
<br>
On 07/16/2017 05:16 PM, Mark Devine wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
T,<br>
<br>
my $x =3D &#39;ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;=
&#39;; my @y =3D ~($x ~~<br>
m:global/ [ &#39;&quot;&#39; &lt;-[ &quot; ]&gt; * &#39;&quot;&#39; | \S+ ]=
 /);<br>
<br>
Mark Devine<br>
<br>
-----Original Message-----<br>
From: ToddAndMargo [mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=
=3D"_blank">ToddAndMargo@zoho.com</a>]<br>
Sent: Sunday, July 16, 2017 7:41 PM<br>
To: perl6-users &lt;<a href=3D"mailto:perl6-users@perl.org" target=3D"_blan=
k">perl6-users@perl.org</a>&gt;<br>
Subject: String to array problem<br>
<br>
Hi All,<br>
<br>
I have been scratching my head trying to figure out how to turn a string wi=
th quotes in it into an array.<br>
<br>
my $x=3D&#39;ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;&#=
39;;<br>
<br>
Desired result:<br>
my @y;<br>
=C2=A0 =C2=A0 =C2=A0 $y[0] =3D &#39;ls&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 $y[1] =3D &#39;-la&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 $y[2] =3D &#39;Program Files&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 $y[3] =3D &#39;Moe Curly Larry&#39;;<br>
<br>
Any words of wisdom?<br>
<br>
Many thanks,<br>
-T<br>
<br>
</blockquote>
<br>
<br>
It kinda, sorta doesn&#39;t work:<br>
<br>
&lt;code&gt;<br>
$ cat ./QuoteArrayTest.pl6<br>
#! /usr/bin/env perl6<br>
<br>
use strict;<br>
<br>
print &quot;\n&quot;;<br>
my $x =3D &#39;ls -al \&quot;Program Files\&quot; \&quot;Moe Curly Larry\&q=
uot;&#39;; my @y =3D~($x ~~ m:global/ [ &#39;&quot;&#39; &lt;-[ &quot; ]&gt=
; * &#39;&quot;&#39; | \S+ ] /); say &quot;$x\n\@y:&quot;;<br>
<br>
for @y.kv -&gt; $index, $value { say &quot;\$y[$index] =3D &lt;$value&gt;&q=
uot;; } print &quot;\n&quot;; &lt;/code&gt;<br>
<br>
ls -al \&quot;Program Files\&quot; \&quot;Moe Curly Larry\&quot;<br>
@y:<br>
$y[0] =3D &lt;ls -al \&quot;Program Files\&quot; \&quot;Moe Curly Larry\&qu=
ot;&gt;<br>
<br>
<br>
What did I do wrong?<br>
</div></div></blockquote><span class=3D"">
<br>
<br>
On 07/16/2017 05:50 PM, Mark Devine wrote:<br>
&gt; T,<br>
&gt;<br></span>
&gt; Sorry (newbie, remember).=C2=A0 For the first question that did not ha=
ve backslash double-quotes:<br>
&gt;<br>
&gt; my ($x, @y);<span class=3D""><br>
&gt; $x =3D &#39;ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quo=
t;&#39;;<br></span>
&gt; @y =3D $x ~~ m:global/ [ &#39;&quot;&#39; &lt;-[ &quot; ]&gt; * &#39;&=
quot;&#39; | \S+ ] /;<br>
&gt; for @y -&gt; $match { say ~$match; }<br>
&gt;<br>
&gt; Don&#39;t know about the second question with backslash double-quotes.=
<br>
&gt;<br>
&gt; Mark<br>
<br>
<br>
That worked.=C2=A0 Thank you!<br>
<br>
&lt;code&gt;<span class=3D""><br>
#! /usr/bin/env perl6<br>
<br>
use strict;<br>
<br>
print &quot;\n&quot;;<br>
my $x =3D &#39;ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;=
&#39;;<br></span>
my @y =3D $x ~~ m:global/ [ &#39;&quot;&#39; &lt;-[ &quot; ]&gt; * &#39;&qu=
ot;&#39; | \S+ ] /;<span class=3D""><br>
say &quot;$x\n\@y:&quot;;<br>
<br>
for @y.kv -&gt; $index, $value { say &quot;\$y[$index] =3D &lt;$value&gt;&q=
uot;; }<br>
print &quot;\n&quot;;<br>
&lt;/code&gt;<br>
<br>
<br></span>
$./QuoteArrayTest.pl6<span class=3D""><br>
<br>
ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;<br>
@y:<br>
$y[0] =3D &lt;ls&gt;<br></span>
$y[1] =3D &lt;-al&gt;<div class=3D"HOEnZb"><div class=3D"h5"><br>
$y[2] =3D &lt;&quot;Program Files&quot;&gt;<br>
$y[3] =3D &lt;&quot;Moe Curly Larry&quot;&gt;<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
<div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=
=3D"ltr"><div>brandon s allbery kf8nh =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sine =
nomine associates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=
=3D"_blank">allbery.b@gmail.com</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0<a href=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery=
@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmon=
ad =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_=
blank">http://sinenomine.net</a></div></div></div>
</div>

--001a114260f004226d055478e340--
0
allbery
7/17/2017 12:57:44 AM
On 07/16/2017 05:57 PM, Brandon Allbery wrote:
> Nested quotes and escapes are handled by the Grammar-based solution I 
> pointed to. You can't handle them in general with a simple regex.

Creating a new grammer?
0
ToddAndMargo
7/17/2017 12:59:00 AM
--001a114576766fcbd9055478f026
Content-Type: text/plain; charset="UTF-8"

Once again: http://www.mail-archive.com/perl6-users@perl.org/msg03986.html

It includes a Grammar that supports arbitrarily nested quotes, which can't
be done in a plain regex: you could maybe handle one level, but not nesting.

On Sun, Jul 16, 2017 at 8:59 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On 07/16/2017 05:57 PM, Brandon Allbery wrote:
>
>> Nested quotes and escapes are handled by the Grammar-based solution I
>> pointed to. You can't handle them in general with a simple regex.
>>
>
> Creating a new grammer?
>



-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--001a114576766fcbd9055478f026
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Once again:=C2=A0<a href=3D"http://www.mail-archive.com/pe=
rl6-users@perl.org/msg03986.html">http://www.mail-archive.com/perl6-users@p=
erl.org/msg03986.html</a><div><br></div><div>It includes a Grammar that sup=
ports arbitrarily nested quotes, which can&#39;t be done in a plain regex: =
you could maybe handle one level, but not nesting.</div></div><div class=3D=
"gmail_extra"><br><div class=3D"gmail_quote">On Sun, Jul 16, 2017 at 8:59 P=
M, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.c=
om" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span> wrote:<br><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><span class=3D"">On 07/16/2017 05:57 PM, Brandon A=
llbery wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Nested quotes and escapes are handled by the Grammar-based solution I point=
ed to. You can&#39;t handle them in general with a simple regex.<br>
</blockquote>
<br></span>
Creating a new grammer?<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><d=
iv>brandon s allbery kf8nh =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sine nomine associ=
ates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=3D"_blank">all=
bery.b@gmail.com</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=
=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery@sinenomine.n=
et</a></div><div>unix, openafs, kerberos, infrastructure, xmonad =C2=A0 =C2=
=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_blank">http:/=
/sinenomine.net</a></div></div></div>
</div>

--001a114576766fcbd9055478f026--
0
allbery
7/17/2017 1:01:29 AM
On 07/16/2017 06:01 PM, Brandon Allbery wrote:
> Once again: http://www.mail-archive.com/perl6-users@perl.org/msg03986.html
> 
> It includes a Grammar that supports arbitrarily nested quotes, which 
> can't be done in a plain regex: you could maybe handle one level, but 
> not nesting.

I understand now.

I was only after one level.

Thank you!

-T
0
ToddAndMargo
7/17/2017 1:03:28 AM
--001a113f77280f1f1505547a6eae
Content-Type: text/plain; charset="UTF-8"

$ perl6
 > my $x='ls -al "Program Files" "Moe Curly Larry"';
ls -al "Program Files" "Moe Curly Larry"
 > &EVAL( "qww<$x>" ).perl
("ls", "-al", "Program Files", "Moe Curly Larry")

How about this?  Obligatory: Much EVAL, very danger wow.

On Sun, Jul 16, 2017 at 6:03 PM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On 07/16/2017 06:01 PM, Brandon Allbery wrote:
>
>> Once again: http://www.mail-archive.com/perl6-users@perl.org/msg03986.ht
>> ml
>>
>> It includes a Grammar that supports arbitrarily nested quotes, which
>> can't be done in a plain regex: you could maybe handle one level, but not
>> nesting.
>>
>
> I understand now.
>
> I was only after one level.
>
> Thank you!
>
> -T
>

--001a113f77280f1f1505547a6eae
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">$ perl6<br><div>=C2=A0&gt; my $x=3D&#39;ls -al &quot;Progr=
am Files&quot; &quot;Moe Curly Larry&quot;&#39;;<br>ls -al &quot;Program Fi=
les&quot; &quot;Moe Curly Larry&quot;<br>=C2=A0&gt; &amp;EVAL( &quot;qww&lt=
;$x&gt;&quot; ).perl<br>(&quot;ls&quot;, &quot;-al&quot;, &quot;Program Fil=
es&quot;, &quot;Moe Curly Larry&quot;)<br><br></div><div>How about this?=C2=
=A0 Obligatory: Much EVAL, very danger wow.<br></div></div><div class=3D"gm=
ail_extra"><br><div class=3D"gmail_quote">On Sun, Jul 16, 2017 at 6:03 PM, =
ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.com"=
 target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex"><span class=3D"">On 07/16/2017 06:01 PM, Brandon Allb=
ery wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Once again: <a href=3D"http://www.mail-archive.com/perl6-users@perl.org/msg=
03986.html" rel=3D"noreferrer" target=3D"_blank">http://www.mail-archive.co=
m/pe<wbr>rl6-users@perl.org/msg03986.ht<wbr>ml</a><br>
<br>
It includes a Grammar that supports arbitrarily nested quotes, which can&#3=
9;t be done in a plain regex: you could maybe handle one level, but not nes=
ting.<br>
</blockquote>
<br></span>
I understand now.<br>
<br>
I was only after one level.<br>
<br>
Thank you!<span class=3D"HOEnZb"><font color=3D"#888888"><br>
<br>
-T<br>
</font></span></blockquote></div><br></div>

--001a113f77280f1f1505547a6eae--
0
bslaabs
7/17/2017 2:48:12 AM
On 07/16/2017 07:48 PM, Brent Laabs wrote:
> $ perl6
>   > my $x='ls -al "Program Files" "Moe Curly Larry"';
> ls -al "Program Files" "Moe Curly Larry"
>   > &EVAL( "qww<$x>" ).perl
> ("ls", "-al", "Program Files", "Moe Curly Larry")
> 
> How about this?  Obligatory: Much EVAL, very danger wow.

I don't understand.  Would you put this into a full executable example?
0
ToddAndMargo
7/17/2017 6:34:31 AM
--001a11393f3cbed8b905547fbf3a
Content-Type: text/plain; charset="UTF-8"

I would put it in an executable example, and I already did.  But here's
another one, if you like.

$ perl6 -e 'my $x = q<ls -al "Program Files" "Moe Curly Larry">; my @y =
&EVAL( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
  @y[0] = 'ls'
  @y[1] = '-al'
  @y[2] = 'Program Files'
  @y[3] = 'Moe Curly Larry'

The last loop is just so it's printed in the way you demonstrated in the
first post.

The main point of me writing that example in the first place is because I
know that the Perl 6 language itself is very good at parsing quotes.  If
you knew what the string was at compile time, you could just write this:
     my @y = qww<ls -al "Program Files" "Moe Curly Larry">;
And it would know exactly how to deal with the quotes.  But I don't know
how to access this functionality of the quote language from within the Perl
6 language.  You can't use qqww directly, because the quote protection is
handled before interpolation, and we want it to happen after.  So I can
eval a qww string instead, and that does work, though it does recognize
kinds of quoting that you wouldn't expect, like dumb quotes or halfwidth
katakana quotes.

All of this is to say that I wish the Str.words method had a way of
applying Perl 6 quoting rules as if it were the qww operator.

On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo <ToddAndMargo@zoho.com>
wrote:

> On 07/16/2017 07:48 PM, Brent Laabs wrote:
>
>> $ perl6
>>   > my $x='ls -al "Program Files" "Moe Curly Larry"';
>> ls -al "Program Files" "Moe Curly Larry"
>>   > &EVAL( "qww<$x>" ).perl
>> ("ls", "-al", "Program Files", "Moe Curly Larry")
>>
>> How about this?  Obligatory: Much EVAL, very danger wow.
>>
>
> I don't understand.  Would you put this into a full executable example?
>

--001a11393f3cbed8b905547fbf3a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div>I would put it in an executable e=
xample, and I already did.=C2=A0 But here&#39;s another one, if you like.<b=
r><br>$ perl6 -e &#39;my $x =3D q&lt;ls -al &quot;Program Files&quot; &quot=
;Moe Curly Larry&quot;&gt;; my @y =3D &amp;EVAL( &quot;qww&lt;$x&gt;&quot;)=
; for @y.kv -&gt; $i, $j { say &quot;=C2=A0 \@y[$i] =3D \c39$j\c39&quot; }&=
#39;<br>=C2=A0 @y[0] =3D &#39;ls&#39;<br>=C2=A0 @y[1] =3D &#39;-al&#39;<br>=
=C2=A0 @y[2] =3D &#39;Program Files&#39;<br>=C2=A0 @y[3] =3D &#39;Moe Curly=
 Larry&#39;<br><br></div>The last loop is just so it&#39;s printed in the w=
ay you demonstrated in the first post.<br><br></div>The main point of me wr=
iting that example in the first place is because I know that the Perl 6 lan=
guage itself is very good at parsing quotes.=C2=A0 If you knew what the str=
ing was at compile time, you could just write this:<br></div>=C2=A0 =C2=A0=
=C2=A0 my @y =3D qww&lt;ls -al &quot;Program Files&quot; &quot;Moe Curly La=
rry&quot;&gt;;<br></div>And it would know exactly how to deal with the quot=
es.=C2=A0 But I don&#39;t know how to access this functionality of the quot=
e language from within the Perl 6 language.=C2=A0 You can&#39;t use qqww di=
rectly, because the quote protection is handled before interpolation, and w=
e want it to happen after.=C2=A0 So I can eval a qww string instead, and th=
at does work, though it does recognize kinds of quoting that you wouldn&#39=
;t expect, like dumb quotes or halfwidth katakana quotes.<br><br></div>All =
of this is to say that I wish the Str.words method had a way of applying Pe=
rl 6 quoting rules as if it were the qww operator.<br></div><div class=3D"g=
mail_extra"><br><div class=3D"gmail_quote">On Sun, Jul 16, 2017 at 11:34 PM=
, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.co=
m" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><span class=3D"">On 07/16/2017 07:48 PM, Brent Laab=
s wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
$ perl6<br>
=C2=A0 &gt; my $x=3D&#39;ls -al &quot;Program Files&quot; &quot;Moe Curly L=
arry&quot;&#39;;<br>
ls -al &quot;Program Files&quot; &quot;Moe Curly Larry&quot;<br>
=C2=A0 &gt; &amp;EVAL( &quot;qww&lt;$x&gt;&quot; ).perl<br>
(&quot;ls&quot;, &quot;-al&quot;, &quot;Program Files&quot;, &quot;Moe Curl=
y Larry&quot;)<br>
<br>
How about this?=C2=A0 Obligatory: Much EVAL, very danger wow.<br>
</blockquote>
<br></span>
I don&#39;t understand.=C2=A0 Would you put this into a full executable exa=
mple?<br>
</blockquote></div><br></div>

--001a11393f3cbed8b905547fbf3a--
0
bslaabs
7/17/2017 9:08:57 AM
>> On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo <ToddAndMargo@zoho.com 
>> <mailto:ToddAndMargo@zoho.com>> wrote:
>> 
>>     On 07/16/2017 07:48 PM, Brent Laabs wrote:
>> 
>>         $ perl6
>>            > my $x='ls -al "Program Files" "Moe Curly Larry"';
>>         ls -al "Program Files" "Moe Curly Larry"
>>            > &EVAL( "qww<$x>" ).perl
>>         ("ls", "-al", "Program Files", "Moe Curly Larry")
>> 
>>         How about this?  Obligatory: Much EVAL, very danger wow.
>> 
>> 
>>     I don't understand.  Would you put this into a full executable example?
>> 
>> 

On 07/17/2017 02:08 AM, Brent Laabs wrote:
> I would put it in an executable example, and I already did.  But here's 
> another one, if you like.
> 
> $ perl6 -e 'my $x = q<ls -al "Program Files" "Moe Curly Larry">; my @y = 
> &EVAL( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
>    @y[0] = 'ls'
>    @y[1] = '-al'
>    @y[2] = 'Program Files'
>    @y[3] = 'Moe Curly Larry'
> 
> The last loop is just so it's printed in the way you demonstrated in the 
> first post.
> 
> The main point of me writing that example in the first place is because 
> I know that the Perl 6 language itself is very good at parsing quotes.  
> If you knew what the string was at compile time, you could just write this:
>       my @y = qww<ls -al "Program Files" "Moe Curly Larry">;
> And it would know exactly how to deal with the quotes.  But I don't know 
> how to access this functionality of the quote language from within the 
> Perl 6 language.  You can't use qqww directly, because the quote 
> protection is handled before interpolation, and we want it to happen 
> after.  So I can eval a qww string instead, and that does work, though 
> it does recognize kinds of quoting that you wouldn't expect, like dumb 
> quotes or halfwidth katakana quotes.
> 
> All of this is to say that I wish the Str.words method had a way of 
> applying Perl 6 quoting rules as if it were the qww operator.
> 

Thank you!

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
ToddAndMargo
7/17/2017 9:17:25 AM
> On 17 Jul 2017, at 11:08, Brent Laabs <bslaabs@gmail.com> wrote:
> All of this is to say that I wish the Str.words method had a way of =
applying Perl 6 quoting rules as if it were the qww operator.

Wouldn=E2=80=99t that be either .split or .comb?


Liz=
0
liz
7/17/2017 9:17:27 AM
--001a11377e8e1d670b055480acd8
Content-Type: text/plain; charset="UTF-8"

Just to make it clear, do not use EVAL() ever on untrusted user input.  In
the example I wrote, if the string contained a '>', anything after that
point would be executed.  While it works, it's a bad idea to use it.

On Mon, Jul 17, 2017 at 2:17 AM, ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo <ToddAndMargo@zoho.com
>>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>>
>>>     On 07/16/2017 07:48 PM, Brent Laabs wrote:
>>>
>>>         $ perl6
>>>            > my $x='ls -al "Program Files" "Moe Curly Larry"';
>>>         ls -al "Program Files" "Moe Curly Larry"
>>>            > &EVAL( "qww<$x>" ).perl
>>>         ("ls", "-al", "Program Files", "Moe Curly Larry")
>>>
>>>         How about this?  Obligatory: Much EVAL, very danger wow.
>>>
>>>
>>>     I don't understand.  Would you put this into a full executable
>>> example?
>>>
>>>
>>>
> On 07/17/2017 02:08 AM, Brent Laabs wrote:
>
>> I would put it in an executable example, and I already did.  But here's
>> another one, if you like.
>>
>> $ perl6 -e 'my $x = q<ls -al "Program Files" "Moe Curly Larry">; my @y =
>> &EVAL( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
>>    @y[0] = 'ls'
>>    @y[1] = '-al'
>>    @y[2] = 'Program Files'
>>    @y[3] = 'Moe Curly Larry'
>>
>> The last loop is just so it's printed in the way you demonstrated in the
>> first post.
>>
>> The main point of me writing that example in the first place is because I
>> know that the Perl 6 language itself is very good at parsing quotes.  If
>> you knew what the string was at compile time, you could just write this:
>>       my @y = qww<ls -al "Program Files" "Moe Curly Larry">;
>> And it would know exactly how to deal with the quotes.  But I don't know
>> how to access this functionality of the quote language from within the Perl
>> 6 language.  You can't use qqww directly, because the quote protection is
>> handled before interpolation, and we want it to happen after.  So I can
>> eval a qww string instead, and that does work, though it does recognize
>> kinds of quoting that you wouldn't expect, like dumb quotes or halfwidth
>> katakana quotes.
>>
>> All of this is to say that I wish the Str.words method had a way of
>> applying Perl 6 quoting rules as if it were the qww operator.
>>
>>
> Thank you!
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

--001a11377e8e1d670b055480acd8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Just to make it clear, do not use EVAL() ever on untrusted=
 user input.=C2=A0 In the example I wrote, if the string contained a &#39;&=
gt;&#39;, anything after that point would be executed.=C2=A0 While it works=
, it&#39;s a bad idea to use it.<br></div><div class=3D"gmail_extra"><br><d=
iv class=3D"gmail_quote">On Mon, Jul 17, 2017 at 2:17 AM, ToddAndMargo <spa=
n dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank=
">ToddAndMargo@zoho.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><span class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">
On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo &lt;<a href=3D"mailto:ToddAn=
dMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a =
href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.c=
om</a>&gt;<wbr>&gt; wrote:<br>
<br>
=C2=A0 =C2=A0 On 07/16/2017 07:48 PM, Brent Laabs wrote:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $ perl6<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&gt; my $x=3D&#39;ls -al &quot;Pro=
gram Files&quot; &quot;Moe Curly Larry&quot;&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ls -al &quot;Program Files&quot; &quot;Moe Curl=
y Larry&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&gt; &amp;EVAL( &quot;qww&lt;$x&gt=
;&quot; ).perl<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (&quot;ls&quot;, &quot;-al&quot;, &quot;Program=
 Files&quot;, &quot;Moe Curly Larry&quot;)<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 How about this?=C2=A0 Obligatory: Much EVAL, ve=
ry danger wow.<br>
<br>
<br>
=C2=A0 =C2=A0 I don&#39;t understand.=C2=A0 Would you put this into a full =
executable example?<br>
<br>
<br>
</blockquote></blockquote>
<br></span><span class=3D"">
On 07/17/2017 02:08 AM, Brent Laabs wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I would put it in an executable example, and I already did.=C2=A0 But here&=
#39;s another one, if you like.<br>
<br>
$ perl6 -e &#39;my $x =3D q&lt;ls -al &quot;Program Files&quot; &quot;Moe C=
urly Larry&quot;&gt;; my @y =3D &amp;EVAL( &quot;qww&lt;$x&gt;&quot;); for =
@y.kv -&gt; $i, $j { say &quot;=C2=A0 \@y[$i] =3D \c39$j\c39&quot; }&#39;<b=
r>
=C2=A0 =C2=A0@y[0] =3D &#39;ls&#39;<br>
=C2=A0 =C2=A0@y[1] =3D &#39;-al&#39;<br>
=C2=A0 =C2=A0@y[2] =3D &#39;Program Files&#39;<br>
=C2=A0 =C2=A0@y[3] =3D &#39;Moe Curly Larry&#39;<br>
<br>
The last loop is just so it&#39;s printed in the way you demonstrated in th=
e first post.<br>
<br>
The main point of me writing that example in the first place is because I k=
now that the Perl 6 language itself is very good at parsing quotes.=C2=A0 I=
f you knew what the string was at compile time, you could just write this:<=
br>
=C2=A0 =C2=A0 =C2=A0 my @y =3D qww&lt;ls -al &quot;Program Files&quot; &quo=
t;Moe Curly Larry&quot;&gt;;<br>
And it would know exactly how to deal with the quotes.=C2=A0 But I don&#39;=
t know how to access this functionality of the quote language from within t=
he Perl 6 language.=C2=A0 You can&#39;t use qqww directly, because the quot=
e protection is handled before interpolation, and we want it to happen afte=
r.=C2=A0 So I can eval a qww string instead, and that does work, though it =
does recognize kinds of quoting that you wouldn&#39;t expect, like dumb quo=
tes or halfwidth katakana quotes.<br>
<br>
All of this is to say that I wish the Str.words method had a way of applyin=
g Perl 6 quoting rules as if it were the qww operator.<br>
<br>
</blockquote>
<br></span>
Thank you!<div class=3D"HOEnZb"><div class=3D"h5"><br>
<br>
-- <br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~~~<br>
Computers are like air conditioners.<br>
They malfunction when you open windows<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~~~<br>
</div></div></blockquote></div><br></div>

--001a11377e8e1d670b055480acd8--
0
bslaabs
7/17/2017 10:15:03 AM
--f403045f89d04ae9d2055480c9fa
Content-Type: text/plain; charset="UTF-8"

And this is another reason for the Grammar solution: it lets you do just
what is needed, in a constrained environment so you don't have any risk
(unless you do something questionable in the Grammar, but then that's on
you.)

On Mon, Jul 17, 2017 at 6:15 AM, Brent Laabs <bslaabs@gmail.com> wrote:

> Just to make it clear, do not use EVAL() ever on untrusted user input.  In
> the example I wrote, if the string contained a '>', anything after that
> point would be executed.  While it works, it's a bad idea to use it.
>
> On Mon, Jul 17, 2017 at 2:17 AM, ToddAndMargo <ToddAndMargo@zoho.com>
> wrote:
>
>> On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo <ToddAndMargo@zoho.com
>>>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>>>
>>>>     On 07/16/2017 07:48 PM, Brent Laabs wrote:
>>>>
>>>>         $ perl6
>>>>            > my $x='ls -al "Program Files" "Moe Curly Larry"';
>>>>         ls -al "Program Files" "Moe Curly Larry"
>>>>            > &EVAL( "qww<$x>" ).perl
>>>>         ("ls", "-al", "Program Files", "Moe Curly Larry")
>>>>
>>>>         How about this?  Obligatory: Much EVAL, very danger wow.
>>>>
>>>>
>>>>     I don't understand.  Would you put this into a full executable
>>>> example?
>>>>
>>>>
>>>>
>> On 07/17/2017 02:08 AM, Brent Laabs wrote:
>>
>>> I would put it in an executable example, and I already did.  But here's
>>> another one, if you like.
>>>
>>> $ perl6 -e 'my $x = q<ls -al "Program Files" "Moe Curly Larry">; my @y =
>>> &EVAL( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
>>>    @y[0] = 'ls'
>>>    @y[1] = '-al'
>>>    @y[2] = 'Program Files'
>>>    @y[3] = 'Moe Curly Larry'
>>>
>>> The last loop is just so it's printed in the way you demonstrated in the
>>> first post.
>>>
>>> The main point of me writing that example in the first place is because
>>> I know that the Perl 6 language itself is very good at parsing quotes.  If
>>> you knew what the string was at compile time, you could just write this:
>>>       my @y = qww<ls -al "Program Files" "Moe Curly Larry">;
>>> And it would know exactly how to deal with the quotes.  But I don't know
>>> how to access this functionality of the quote language from within the Perl
>>> 6 language.  You can't use qqww directly, because the quote protection is
>>> handled before interpolation, and we want it to happen after.  So I can
>>> eval a qww string instead, and that does work, though it does recognize
>>> kinds of quoting that you wouldn't expect, like dumb quotes or halfwidth
>>> katakana quotes.
>>>
>>> All of this is to say that I wish the Str.words method had a way of
>>> applying Perl 6 quoting rules as if it were the qww operator.
>>>
>>>
>> Thank you!
>>
>>
>> --
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Computers are like air conditioners.
>> They malfunction when you open windows
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>
>


-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--f403045f89d04ae9d2055480c9fa
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">And this is another reason for the Grammar solution: it le=
ts you do just what is needed, in a constrained environment so you don&#39;=
t have any risk (unless you do something questionable in the Grammar, but t=
hen that&#39;s on you.)</div><div class=3D"gmail_extra"><br><div class=3D"g=
mail_quote">On Mon, Jul 17, 2017 at 6:15 AM, Brent Laabs <span dir=3D"ltr">=
&lt;<a href=3D"mailto:bslaabs@gmail.com" target=3D"_blank">bslaabs@gmail.co=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
Just to make it clear, do not use EVAL() ever on untrusted user input.=C2=
=A0 In the example I wrote, if the string contained a &#39;&gt;&#39;, anyth=
ing after that point would be executed.=C2=A0 While it works, it&#39;s a ba=
d idea to use it.<br></div><div class=3D"HOEnZb"><div class=3D"h5"><div cla=
ss=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Jul 17, 2017 at 2=
:17 AM, ToddAndMargo <span dir=3D"ltr">&lt;<a href=3D"mailto:ToddAndMargo@z=
oho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;</span> wrote:<br><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><span><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex">
On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo &lt;<a href=3D"mailto:ToddAn=
dMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a =
href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.c=
om</a>&gt;<wbr>&gt; wrote:<br>
<br>
=C2=A0 =C2=A0 On 07/16/2017 07:48 PM, Brent Laabs wrote:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $ perl6<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&gt; my $x=3D&#39;ls -al &quot;Pro=
gram Files&quot; &quot;Moe Curly Larry&quot;&#39;;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ls -al &quot;Program Files&quot; &quot;Moe Curl=
y Larry&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&gt; &amp;EVAL( &quot;qww&lt;$x&gt=
;&quot; ).perl<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (&quot;ls&quot;, &quot;-al&quot;, &quot;Program=
 Files&quot;, &quot;Moe Curly Larry&quot;)<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 How about this?=C2=A0 Obligatory: Much EVAL, ve=
ry danger wow.<br>
<br>
<br>
=C2=A0 =C2=A0 I don&#39;t understand.=C2=A0 Would you put this into a full =
executable example?<br>
<br>
<br>
</blockquote></blockquote>
<br></span><span>
On 07/17/2017 02:08 AM, Brent Laabs wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I would put it in an executable example, and I already did.=C2=A0 But here&=
#39;s another one, if you like.<br>
<br>
$ perl6 -e &#39;my $x =3D q&lt;ls -al &quot;Program Files&quot; &quot;Moe C=
urly Larry&quot;&gt;; my @y =3D &amp;EVAL( &quot;qww&lt;$x&gt;&quot;); for =
@y.kv -&gt; $i, $j { say &quot;=C2=A0 \@y[$i] =3D \c39$j\c39&quot; }&#39;<b=
r>
=C2=A0 =C2=A0@y[0] =3D &#39;ls&#39;<br>
=C2=A0 =C2=A0@y[1] =3D &#39;-al&#39;<br>
=C2=A0 =C2=A0@y[2] =3D &#39;Program Files&#39;<br>
=C2=A0 =C2=A0@y[3] =3D &#39;Moe Curly Larry&#39;<br>
<br>
The last loop is just so it&#39;s printed in the way you demonstrated in th=
e first post.<br>
<br>
The main point of me writing that example in the first place is because I k=
now that the Perl 6 language itself is very good at parsing quotes.=C2=A0 I=
f you knew what the string was at compile time, you could just write this:<=
br>
=C2=A0 =C2=A0 =C2=A0 my @y =3D qww&lt;ls -al &quot;Program Files&quot; &quo=
t;Moe Curly Larry&quot;&gt;;<br>
And it would know exactly how to deal with the quotes.=C2=A0 But I don&#39;=
t know how to access this functionality of the quote language from within t=
he Perl 6 language.=C2=A0 You can&#39;t use qqww directly, because the quot=
e protection is handled before interpolation, and we want it to happen afte=
r.=C2=A0 So I can eval a qww string instead, and that does work, though it =
does recognize kinds of quoting that you wouldn&#39;t expect, like dumb quo=
tes or halfwidth katakana quotes.<br>
<br>
All of this is to say that I wish the Str.words method had a way of applyin=
g Perl 6 quoting rules as if it were the qww operator.<br>
<br>
</blockquote>
<br></span>
Thank you!<div class=3D"m_-4572291811180819341HOEnZb"><div class=3D"m_-4572=
291811180819341h5"><br>
<br>
-- <br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~~~<br>
Computers are like air conditioners.<br>
They malfunction when you open windows<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~~~<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
<div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=
=3D"ltr"><div>brandon s allbery kf8nh =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sine =
nomine associates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=
=3D"_blank">allbery.b@gmail.com</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0<a href=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery=
@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmon=
ad =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_=
blank">http://sinenomine.net</a></div></div></div>
</div>

--f403045f89d04ae9d2055480c9fa--
0
allbery
7/17/2017 10:23:12 AM
Reply: