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.
01:36 Kaipei left 01:40 Kaiepi joined 02:17 discord-raku-bot left, discord-raku-bot joined 02:36 Kaiepi left 04:43 Kaiepi joined
SmokeMachine lizmat: thank you for your answer! Another question: will rak have a `-o` option? 07:31
08:09 dakkar joined
lizmat to output to a file? 08:30
SmokeMachine lizmat: no, to show only the matched part of the line 09:48
lizmat ah, ok
SmokeMachine for example: usercontent.irccloud-cdn.com/file/...2%402x.png 09:51
lizmat what if multiple parts of the line match? all of them? or just the first ? 09:55
Nemokosch Does Raku not have stuff like the @F record variable in Perl? 10:15
lizmat "The array @F contains the fields of each line read in when autosplit mode is turned on. See perlrun for the -a switch. This array is package-specific, and must be declared or given a full package name if not in package main when running under strict 'vars'." 10:16
could you give me an example of how you'd see that in Raku ?
I can't recall ever having used @F in Perl myself 10:19
Nemokosch ^^ 10:20
Nemokosch I liked it for proper `cut` 10:23
that splits on any whitespace, not one instance of a certain character
psg aux | perl -lane 'print $F[1]'
or something
not a big deal frankly, just wanted to confirm
SmokeMachine lizmat: I think it should be all matched parts of the line… 11:04
lizmat ok, separated by space?
SmokeMachine usercontent.irccloud-cdn.com/file/...4%402x.png
each one on its own line (IMHO) 11:05
Nahita \*witnessing an API design live\* exciting 11:06
Nemokosch 😂 😂
lizmat SmokeMachine: and just repeat the line number ? 11:07
SmokeMachine that's a good question... maybe not add line numbers if `-o`? Could line numbers be optional and disabled by default? (sorry, I'm just thinking that it would be easier to pipe) 11:08
lizmat yeah, line numbers are going to be switchoffable 11:10
SmokeMachine about @F, I'd use that with something like this: usercontent.irccloud-cdn.com/file/...5%402x.png 11:11
Nemokosch also legit 11:13
I consider it an improved `cut`
SmokeMachine lizmat: would you mind if I do one more feature request? 11:15
Nemokosch and if I can do it in Perl, why start with something additional that I cannot meaningfully use for anything else? (awk, that is)
lizmat rak '{ my @F = .split(":"); @F[0] if @F > 5 }' /etc/passwd 11:16
SmokeMachine: ^^ would that work for you ?
SmokeMachine: maybe start making issues for them in github.com/lizmat/App-Rak ? 11:17
SmokeMachine the @F, I'd like to have it in raku, better than in rak...
but my feature request for rak is kinda related to that... it would be have a way to do something like: `rak '/pattern/' --by-line '.uc #any transformation'`and/or `rak '/pattern/' --by-file '.IO.absolute # any transformation'`. Anything inside --by-line would be a block that would run for each line where pattern was matched and the same on --by-file, but it would receive the file. probably those options should conflict 11:22
and rak would print the return of those blocks...
lizmat well, my example above would do that already? 11:25
if you specify a Callable, and it doesn't return a Bool or an Empty, it would be considered something to say ?
SmokeMachine not for files, would it?
I really like your idea 11:26
maybe it could have a way to specify that should run by file instead of by line? 11:27
Nemokosch Anyway, I already like this module, just by hearing about it 11:29
I write `find . -type f -exec grep "blah" {} \; -print` several times a day...
SmokeMachine I have another idea but that one maybe should be in a different tool, not rak... that would be: if you are searching by code, do that by act instead of by string... so, you could to: `$TOOL 'loop { .. }' and it would understand you are looking for any (infinity) loop, get every Raku code on the current path, get its past and search for a (infinite) loop on it... 11:32
Nemokosch: why not `grep -R`? 11:33
(I suppose my AST search would not perform very well... but I think that would be very useful...)
Nemokosch I haven't heard of -R in the first place, to be frank 11:38
but either way, I won't be able to abandon the find-exec-grep pattern
because Solaris 8 🤪
also, can I silence "is a folder" type of errors? 11:40
SmokeMachine you mean with -R? 11:43
usercontent.irccloud-cdn.com/file/...6%402x.png 11:44
I like `grep -R` but because I usually need it inside git repos, I usually use `git grep` more... 11:47
13:48 discord-raku-bot left, discord-raku-bot joined 13:53 discord-raku-bot left, discord-raku-bot joined 16:35 dakkar left 20:23 discord-raku-bot left, discord-raku-bot joined 20:24 gfldex left 20:26 gfldex joined 20:28 discord-raku-bot left, discord-raku-bot joined 20:59 discord-raku-bot left, discord-raku-bot joined 21:26 discord-raku-bot left, discord-raku-bot joined