Because << >> is a double-quoted index (same as quote words «»), so it interpolates the variable. <> is a single-quoted string, so it doesn't interpolate.
But what you really want here is %x{$z}, so you don't bother with string interpolation at all, and pass the String variable directly. On Fri, Sep 14, 2018 at 11:59 PM ToddAndMargo <toddandma...@zoho.com> wrote: > Hi All, > > Why does `$y =%x<<$z>>` work in the following and > `$y =%x<$z>` and `$y =%x<"$z"> do not work? > > $ p6 'my Str %x=("Jan"=>"01", "Feb"=>"02"); > my Str $z="Jan"; > my $y =%x<<$z>>; > say "$y";' > 01 > > Why did I get it right? > > > Many thanks, > -T >