Re: interpolating the return from embedded code in a regexp

2020-06-17 Thread William Michels via perl6-users
Just wondering if the docs describe how to access an "inner" capture once saved to a variable? If not maybe the code below would be helpful (from yary's last example, REPL output): > my $capture = "1122" ~~ /(\d) {} :my $c=$0; ($c (\d) $0)/ 「1122」 0 => 「1」 1 => 「122」 0 => 「2」 > say $capture

Re: interpolating the return from embedded code in a regexp

2020-06-17 Thread Joseph Brenner
On 6/15/20, yary wrote: > The Match docs can be clearer on when to use {} and when it isn't needed, I agree, in fact I'm inclined to think this is an actual bug (design error?). It's pretty strange that the two kinds of code interpolation behave so differently: $(...) requires you to do

Re: interpolating the return from embedded code in a regexp

2020-06-17 Thread Joseph Brenner
Brad Gilbert wrote: > You don't want to use <{…}>, you want to use "" > if $line ~~ / (^P\d+) \s+ {} "%products{$0}" / { Well, as contrived examples go this one could be improved. Instead of directly dereferencing a hash, maybe I should've used a sub call. > Note that {} is there to

Re: Code assertions to spy on regexps behavior

2020-06-17 Thread Joseph Brenner
> It doesn't have to be an assertion. Just a code block would do the same. Yes, good point. In the docs, in the section Regex Interpolation, they don't mention that feature, presumably because it literally does no interpolation, but I'd argue that the null case is worth including in this table:

Re: Help converting CArray[uint8] to Blob

2020-06-17 Thread Elizabeth Mattijsen
Shorter, and much more readable, I'd say: my Blob $blob = blob-from-carray($ed.data, size=>$ed.data_size); say "bindata = { now - INIT now }"; The term "now" is short for "DateTime.now.Instant" The INIT phaser is run when the program is started: it returns the value that was obtained

Re: Help converting CArray[uint8] to Blob

2020-06-17 Thread David Santiago
Super! That what i was looking for, i changed the code to: my Instant $init = DateTime.now.Instant; my Blob $blob = blob-from-carray($ed.data, size=>$ed.data_size); say "bindata = {DateTime.now.Instant-$init}"; Output: Bindata= 0.00060054 So it passed from approx 1.1 to 0.0006 secs. That's

Re: Help converting CArray[uint8] to Blob

2020-06-17 Thread Ralph Mellor
> Unfortunately, i get the error "Error > X::AdHoc+{X::Await::Died}+{X::React::Died}: Don't know how many elements a C array returned from a library" I googled the error message and got a bunch of matches including this:

Re: Help converting CArray[uint8] to Blob

2020-06-17 Thread David Santiago
Hi! > $ed.data.head($ed.data_size) Unfortunately, i get the error "Error X::AdHoc+{X::Await::Died}+{X::React::Died}: Don't know how many elements a C array returned from a library" > > my uint8 @data = $ed.data[0..$ed.data_size-1].Array; > > my Blob $bindata = Blob[uint8].new(@data); > >