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 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-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 Brent Laabs
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; my @y = ( "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

Re: String to array problem

2017-07-17 Thread ToddAndMargo
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" > ( "qww<$x>" ).perl ("ls", "-al", "Program Files", "Moe Curly Larry") How about this? Obligatory: Much EVAL, very danger wow. I don't

Re: String to array problem

2017-07-16 Thread Brent Laabs
$ perl6 > my $x='ls -al "Program Files" "Moe Curly Larry"'; ls -al "Program Files" "Moe Curly Larry" > ( "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

RE: String to array problem

2017-07-16 Thread Mark Devine
tch; } Don't know about the second question with backslash double-quotes. Mark -Original Message- From: ToddAndMargo [mailto:toddandma...@zoho.com] Sent: Sunday, July 16, 2017 8:35 PM To: perl6-users <perl6-us...@perl.org> Subject: Re: String to array problem On 07/16/2017 05:16 PM, Mark Devi

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-us...@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-us...@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 Brandon Allbery
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

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-us...@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-us...@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-us...@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 Mark Devine
rs <perl6-us...@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';

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 <perl6-us...@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

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

String to array problem

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