Aha. Thanks
On 10/01/2022 15:59, Gianni Ceccarelli wrote:
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]`…)