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.
lizmat PSA: pl6anet.org is now officially offline, if you were still using that, please use planet.raku.org instead 08:55
wafflus when looping thought a file how do i get the next line after i match? 18:55
nemokosch Could you illustrate it? 19:08
wafflus when /\.ITEM/' {get next line and print } 19:11
wafflus maybe i need a state var 19:16
nemokosch you can retrieve a line from a file handle using get, if that helps 19:18
the other solution I'm looking into is with toggle 19:21
wafflus yeah i've been messing around alot as well lol 19:22
i;m sure i will get it using the get it took me a few mine to understand how to use it 19:27
nemokosch at the end of the day, it depends what you want to do, too 19:28
I managed it with toggle eventually
'filename'.IO.lines.toggle(:off, *.match(pattern)) is the sequence of lines starting from the match 19:29
wafflus ok thanks
nemokosch if you need a more stateful, more procedural processing, I'd use something like
loop (my $fh = open('filename'.IO), my $line = $fh.get; $line.defined; $line = $fh.get) { ... } 19:30
do something depending on the value of $line, maybe fetch the next line 19:31
wafflus k iyeah that's what i was trying to do :)
nemokosch keep in mind that in this case, $fh and $line belong to the surrounding scope so they are visible after the loop as well 19:33
wafflus so confusing i'll get it eventually 19:36
wafflus raku -e ' loop (my $fh = open("./install-next.txt".IO), my $line = $fh.get; $line.defined; $line = $fh.get) {.say when /\.ITEM/ }' 19:39
why am i geting this error all the time Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
  in block at -e line 1
i got it cu around thanks 19:49
nemokosch because you are calling .say without having a topic set 21:17
you could wrap it in given $line { } 21:18