On Mon, 10 Jan 2022 15:41:04 +0000
Richard Hainsworth <rnhainswo...@gmail.com> wrote:

> Using REPL I got
> 
>  > my $s = '\'<favicon />\''  
> '<favicon />'
>  > $s.subst( / \' ~ \' (.+) /, $0)  
> Use of Nil in string context
>    in block <unit> at <unknown file> line 1

That error message (which is a bit LTA) refers to the `$0`. As
https://docs.raku.org/routine/subst#Callable shows, you need to write:

    $s.subst( / \' ~ \' (.+) /, { $0 })

>  > my $t = '{<favicon />}'  
> {<favicon />}
>  > $t.subst( / \{ ~ \} (.+) /, $0)  
> <favicon />

This only appear to work because you're running it in the same REPL
session; the previous `subst` had the side-effect of setting `$0`
(well, it sets `$/`, but `$0` is an alias for `$/[0]`…)

-- 
        Dakkar - <Mobilis in mobile>
        GPG public key fingerprint = A071 E618 DD2C 5901 9574
                                     6FE2 40EA 9883 7519 3F88
                            key id = 0x75193F88

Reply via email to