This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:19 MasterDuke joined 04:25 defaultxr left 05:19 ab5tract left, ab5tract joined 06:59 SmokeMachine left 07:00 SmokeMachine joined 14:18 deadmarshal_ left, deadmarshal_ joined
thowe the docs don't seem to cover this, so what does a "g" mean in a regex? Like when I see something like m:g/\d/ 21:43
lizmat :g is short for :global 21:46
m: say "1234" ~~ m/ \d / 21:47
camelia 「1」
lizmat m: say "1234" ~~ m:g/ \d /
camelia (「1」 「2」 「3」 「4」)
lizmat aka, return all possible matches
librasteve thowe: this is the best doc for raku regex imo ... docs.raku.org/language/regexes#Common_adverbs 21:49
thowe Ah, I see global in a different location... Doesn't help me solve my issue though. Red herring. Proc::Async must be where I need to look.
librasteve yeah - raku moved the adverbs from perl re (since they are just now regular raku adverbs ;-)) 21:50
thowe I suspect Proc::Async.stdout.tap doesn't have a way to specify that it should split on newlines the way $proc.stdout.lines does. 21:53
With tap you can get the output in a variable like so "$supply.tap(-> $v { say "$v" });" but I can't seem to figure out how to use a variable other than $_ when doing "react { whenever $proc.stdout.lines {" 22:16
how would I get lines in $line? 22:17
for example
looking at docs.raku.org/type/Proc/Async
librasteve thowe: it would be very helpful to see you code alternatives in a gist or similar 22:18
thowe Well, the documentation itself shows a good example of what I mean... The first example shows "$proc.stdout.lines" and then the line is in $_. The second example, "Proc::Async without using a react block:", shows $proc.stdout.tap creating "$v". 22:23
How would I do the equiv of creating "$v" with the lines method?
Might be a moot point as I can't get a react block to actually do anything. 22:30
here's both versions in one snippet: gitlab.com/-/snippets/3728658 22:35
The problem with tap, is that the lines I am getting from my maillog will be broken up, and so I can't rely on having an actual line to parse. 22:36
My problems with the lines/react method are legion. How do you make your program do anything else other than the react loop? How do you get the line as a variable you name like with tap? Oh, yeah, also, why does it not actually seem to get any data ever... 22:38
tap seems to work until I get a half line, and then the other half of the line as another line.
I got this from an example in the book "Raku Recipes" but it doesn't really work. 22:39
recipe 2-3
I'm sure most of my confusion is just not understanding reactive programs or supplies or whatever, but the question about assigning a variable to lines remains 22:46
I'm really getting lost in the weeds here, though. What I would really like is to know how to get tap to take the lines as they are given and not break them up. 22:48
so, trying to do something where I assemble the lines.. 23:34
ab5tract When creating a block, you can specify a signature. This allows you to name the parameter and reference it by that name in the block 23:35
m: (-> $param { dd :$param })(42) 23:36
camelia :param(42)
ab5tract This works also for if
m: my %h = :k(‘v’); if %h<k> -> $value { dd :$value } 23:38
camelia :value("v")
ab5tract Or anywhere that a block can fit 23:39
The reason the react block doesn’t get any data is because you have to call start on the proc sync object 23:43
You can have this happen in your react block or assign the start promise into a variable before the react block is defined 23:44
docs.raku.org/type/Proc/Async 23:45