The original error you quoted was about use of Nil. I couldn't reproduce this by assigning Nil to a variable, turns out that's because such an assignment is specified to set the variable to the default value of the type of the variable. my $x = Nil gives (Any), my Str $y = Nil gives (Str), and only my Nil $z = Nil actually gives Nil. In your more complete code snippet it looks like the $Line ~~ match fails, leaving $0 with the value Nil, leading to the error you first posted.
I think Patrick is right that using braces to control interpolation is a good idea. On 30 April 2018 at 21:21, ToddAndMargo <toddandma...@zoho.com> wrote: > >> On Sun, Apr 29, 2018 at 10:20:48PM -0700, ToddAndMargo wrote: >>> >>> On 04/29/2018 10:12 PM, ToddAndMargo wrote: >>>> >>>> On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: >>>>> >>>>> There is not enough context to answer or even reproduce the problem - >>>>> how are the variables declared and what values do they have just prior >>>>> to this line? >>> >>> >>> Some simpler examples: >>> >>> $ perl6 -e 'my $x="abcde<br>"; say $x;' >>> abcde<br> >>> >>> $ perl6 -e 'my $x="abcde"; my $y="$x" ~ "<br>"; say $y;' >>> abcde<br> >>> >>> $ perl6 -e 'my $x="abcde"; my $y="$x<br>"; say $y;' >>> Type Str does not support associative indexing. >>> in block <unit> at -e line 1 >>> >>> $ perl6 -e 'my $x="abcde"; my $y="{$x}<br>"; say $y;' >>> abcde<br> >>> >>> $ perl6 -e 'my $x="abcde"; my $y="$x\<br\>"; say $y;' >>> abcde<br> >>> >>> >>> So when is "<" and ">" a letter and when is it a redirect? >> >> > > > On 04/30/2018 12:09 AM, Patrick Spek wrote: >> It seems like in the one case it throws an error, it's because `<>` are >> being >> used to index a hash. Or at least tried to. In Perl 6, you can access a >> Hash's >> elements using `%foo<bar>`, which will access the index `bar` on the Hash >> `%foo`. >> >> The other cases are explicitly not referring to a variable, or have >> delimiters >> in place to make it known to the compiler that you're not trying to access >> a >> Hash index. >> >> The error you're getting is "Type Str does not support associative >> indexing.", >> which is correct, though perhaps a little unexpected for you. `$x` >> contains a >> Str, not a Hash, but the `<br>` still try to retrieve the index `br` from >> it. >> The solution is to use any of the other options you're using, with my >> personal >> preference going out to `{$x}<br>`. >> > > > Hi Patrick, > > Now it makes sense. It was trying to resolve a hash. > > Thank you! > > -T > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~