OT: catch the bash error?

2018-08-03 Thread ToddAndMargo
Hi All, I wanted to do a mass rename of "Apple.*" to "Mac.*" with bash and I could not figure out the error. I eventually did find it and I have to blame Perl for it! Chuckle. for F in Apple*; do $G=$(echo $F | sed -e 's/^Apple/Mac/'); mv $F $G; echo "$F --> $G"; done Did you catch the erro

Re: Catching exceptions in expressions

2018-08-03 Thread Patrick R. Michaud
Yes; but then I think that something like infix: probably just ends up as a macro somehow. I just didn't know the state of macros in Perl 6 well enough to be able to head down that route. :) Pm On Fri, Aug 03, 2018 at 10:32:41PM +0200, Elizabeth Mattijsen wrote: > Sometimes I wish we could us

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:36 AM, Parrot Raiser wrote: If I've interpreted this https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges correctly, ^ is "start of string" +alnum means "in the alphanumeric set" -alpha means "not in the purely alphabetic set" i.e. <+alnum -alpha> me

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:52 AM, Patrick R. Michaud wrote: The + essentially indicates that this is a character-class match. It's to distinguish things from <.alpha>, , , <-alpha>, and (among others). Thank you!

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:48 AM, Timo Paulssen wrote: The + is required, perhaps because the first character after the opening < is supposed to determine exactly what thing it is? Not sure about that. The + and - is a bit like "start at nothing, add all alnums, then subtract all alphas". The + after the <

Re: parsing in different modes

2018-08-03 Thread Theo van den Heuvel
Hi all, My attempt at a solution below does not work. In larger examples the decr gets called before the actions within Sum are processed. Maybe my hunch that this would cause time order problems was correct. I need to do some more researching. I'll post my findings. best wishes, Theo van

Re: Catching exceptions in expressions

2018-08-03 Thread Elizabeth Mattijsen
Sometimes I wish we could use Thunk as a type: sub infix:(Thunk:D $block, $otherwise) { } which would then allow you to do: my $sixdivzero = divide(6,0) rescue -1; # note absence of curlies One can wish, can’t one? Liz > On 3 Aug 2018, at 22:18, Patrick R. Michaud wrote: > > Maybe somet

Re: Catching exceptions in expressions

2018-08-03 Thread Patrick R. Michaud
Maybe something like...? $ cat t.p6 sub infix:(Callable $block, $otherwise) { CATCH { return $otherwise; } $block(); } sub divide($a, $b) { die "Zero denominator" if $b == 0; $a / $b } my $sixdivzero = { divide(6,0) } rescue -1; say "6/0 = ", $sixdivzero; my $sixdivtwo = { divide(6,2) }

Re: Catching exceptions in expressions

2018-08-03 Thread Simon Proctor
Hi Sean. I hope my second answer in stackoverflow gets closer to what you want. I am still trying to think of a more idiomatic way of handling to situation. On Fri, 3 Aug 2018, 19:29 Sean McAfee, wrote: > I posted about this subject on Stack Overflow yesterday[1], but I chose a > poor example

Re: need regex help

2018-08-03 Thread Patrick R. Michaud
The + essentially indicates that this is a character-class match. It's to distinguish things from <.alpha>, , , <-alpha>, and (among others). Pm On Fri, Aug 03, 2018 at 08:48:24PM +0200, Timo Paulssen wrote: > The + is required, perhaps because the first character after the opening > < is sup

Re: need regex help

2018-08-03 Thread Timo Paulssen
The + is required, perhaps because the first character after the opening < is supposed to determine exactly what thing it is? Not sure about that. The + and - is a bit like "start at nothing, add all alnums, then subtract all alphas". The + after the < > is just to match it any number of times, but

Re: need regex help

2018-08-03 Thread Brandon Allbery
That document also says that _ is considered a letter (that is, is matched by : https://docs.perl6.org/language/regexes#Predefined_Character_Classes), so that's the same thing as . I observed that earlier as well. On Fri, Aug 3, 2018 at 2:37 PM Parrot Raiser <1parr...@gmail.com> wrote: > If I've

Re: need regex help

2018-08-03 Thread Parrot Raiser
If I've interpreted this https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges correctly, ^ is "start of string" +alnum means "in the alphanumeric set" -alpha means "not in the purely alphabetic set" i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_ +

Catching exceptions in expressions

2018-08-03 Thread Sean McAfee
I posted about this subject on Stack Overflow yesterday[1], but I chose a poor example of something that raises an exception (dividing by zero, which apparently doesn't necessarily do so) on which the answers have mostly focused. I was looking for a way to evaluate an expression, and if the expres

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/02/2018 05:18 AM, Timo Paulssen wrote: Is this what you want? perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' 「12345」 perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' Nil HTH   - Timo What does the following do? +alnum (why does it need the "+"?) -alpha (I presume "-" me

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/02/2018 05:18 AM, Timo Paulssen wrote: Is this what you want? perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' 「12345」 perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' Nil HTH   - Timo A piece of art. Thank you!