Re: What to do when a pattern match fails

2017-03-14 Thread Andy Bach
On Mon, Mar 13, 2017 at 8:40 PM, ToddAndMargo wrote: > To grab something from the middle: > > $ perl6 -e 'my $x="blah(good stuff 123)yuk"; > $x ~~ m |.*\((.*)\)|; > say "$x\n\$0=<$0>";' > Just a further refinement - if you want only the stuff between inner

Re: What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
On 03/13/2017 04:12 PM, ToddAndMargo wrote: On 03/13/2017 02:06 PM, ToddAndMargo wrote: Hi All, $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";' Use of Nil in string context in block at -e line 1 ab12cd $0=<> With out the "q" in this, it works. I deliberately put the

Re: What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
On 03/13/2017 02:06 PM, ToddAndMargo wrote: Hi All, $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";' Use of Nil in string context in block at -e line 1 ab12cd $0=<> With out the "q" in this, it works. I deliberately put the "q" to see what would happen when a patter was

Re: What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
On 03/13/2017 04:03 PM, yary wrote: On Mon, Mar 13, 2017 at 6:16 PM, ToddAndMargo > wrote: So if it only catches some of them, it will still return false? There is no catching some of them- either the pattern matches and all are

Re: What to do when a pattern match fails

2017-03-13 Thread yary
On Mon, Mar 13, 2017 at 6:16 PM, ToddAndMargo wrote: > So if it only catches some of them, it will still return false? There is no catching some of them- either the pattern matches and all are caught, or the pattern fails and none are caught. If you can show us an

Re: What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
On 03/13/2017 02:28 PM, Elizabeth Mattijsen wrote: On 13 Mar 2017, at 22:20, ToddAndMargo wrote: On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote: On 13 Mar 2017, at 22:06, ToddAndMargo wrote: Hi All, $ perl6 -e 'my $x="ab12cd"; $x ~~

Re: What to do when a pattern match fails

2017-03-13 Thread Elizabeth Mattijsen
> On 13 Mar 2017, at 22:20, ToddAndMargo wrote: > > On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote: >> >>> On 13 Mar 2017, at 22:06, ToddAndMargo wrote: >>> >>> Hi All, >>> >>> $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say

Re: What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote: On 13 Mar 2017, at 22:06, ToddAndMargo wrote: Hi All, $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";' Use of Nil in string context in block at -e line 1 ab12cd $0=<> With out the "q" in this,

Re: What to do when a pattern match fails

2017-03-13 Thread Elizabeth Mattijsen
> On 13 Mar 2017, at 22:06, ToddAndMargo wrote: > > Hi All, > > $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";' > Use of Nil in string context in block at -e line 1 > ab12cd > $0=<> > > With out the "q" in this, it works. I deliberately put >

What to do when a pattern match fails

2017-03-13 Thread ToddAndMargo
Hi All, $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";' Use of Nil in string context in block at -e line 1 ab12cd $0=<> With out the "q" in this, it works. I deliberately put the "q" to see what would happen when a patter was not found. Is there a way around the "use