Re: String to array problem

2017-07-17 Thread Brandon Allbery
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 wrote:

Re: String to array problem

2017-07-17 Thread Brent Laabs
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 wrote: >

Re: String to array problem

2017-07-17 Thread ToddAndMargo
On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo > 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"

Re: String to array problem

2017-07-17 Thread Elizabeth Mattijsen
> On 17 Jul 2017, at 11:08, Brent Laabs 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’t that be either .split or .comb? Liz

RE: String to array problem

2017-07-16 Thread Mark Devine
s return Match object, they need their match string coerced out with '~'. ~( ); Mark -Original Message- From: ToddAndMargo [mailto:toddandma...@zoho.com] Sent: Sunday, July 16, 2017 8:26 PM To: perl6-users <perl6-users@perl.org> Subject:

RE: String to array problem

2017-07-16 Thread Mark Devine
rgo [mailto:toddandma...@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 ~~

Re: String to array problem

2017-07-16 Thread ToddAndMargo
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.

Re: String to array problem

2017-07-16 Thread ToddAndMargo
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?

Re: String to array problem

2017-07-16 Thread Brandon Allbery
dandma...@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 &quo

Re: String to array problem

2017-07-16 Thread ToddAndMargo
-Original Message- From: ToddAndMargo [mailto:toddandma...@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

Re: String to array problem

2017-07-16 Thread ToddAndMargo
-Original Message- From: ToddAndMargo [mailto:toddandma...@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

Re: String to array problem

2017-07-16 Thread ToddAndMargo
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:toddandma...@zoho.com] Sent: Sunday, July 16, 2017 7:41 PM To:

RE: String to array problem

2017-07-16 Thread Mark Devine
T, my $x = 'ls -al "Program Files" "Moe Curly Larry"'; my @y = ~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /); Mark Devine -Original Message- From: ToddAndMargo [mailto:toddandma...@zoho.com] Sent: Sunday, July 16, 2017 7:41 PM To: perl6-users Subject: String

Re: String to array problem

2017-07-16 Thread ToddAndMargo
-Original Message- From: ToddAndMargo [mailto:toddandma...@zoho.com] Sent: Sunday, July 16, 2017 7:41 PM To: perl6-users 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

Re: String to array problem

2017-07-16 Thread Brandon Allbery
On Sun, Jul 16, 2017 at 7:41 PM, ToddAndMargo 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