> On Sep 5, 2022, at 1:54 AM, Marc Chantreux <m...@unistra.fr> wrote:
--snip of Bill's pointer to Mathew's email--
> I tried this line but got an immutability problem. I tried
> multiple work around with no success for the moment.
> <<. raku -e 'lines.IO.map: {repeat {.put} while not .=parent ~~ "/" }'
> /var/log/messages
--snip--

> On Sep 5, 2022, at 2:40 AM, Fernando Santagata <nando.santag...@gmail.com> 
> wrote:
> you can get around the immutability problem:
> raku -e '"/var/log/messages".IO.map: -> $_ is copy {repeat {.put} while ! ($_ 
> .= parent ~~ "/") }'

--snip--

The use of `.parent` inspired me to think of this shorter solution, via the 
Sequence Operator:
$ raku -e '.put for "/var/log/messages".IO, *.parent …^ "/";'
        /var/log/messages
        /var/log
        /var

https://docs.raku.org/language/operators#infix_...

-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)

Reply via email to