perl6 -e ' my %x = ( "a" => "A", "b" => "B", "c" => "C" );my $y="b"; %x<$y>="BB"; say %x;'
{$y => BB, a => A, b => B, c => C}
<code>
#!/usr/bin/env perl6
# This test is based on the following one liner that works
# perl6 -e ' my %x = ( "a" => "A", "b" => "B", "c" => "C" );my $y="b"; %x<$y>="BB"; say %x;'
# {$y => BB, a => A, b => B, c => C}
my $LineKey;
my $LineValue;
my %x = ( "a" => "", "b" => "", "c" => "" );
my @y=qw[ a=A b=B c=C ];
say @y;
say %x;
for @y -> $Line {
$Line ~~ m/(.*?)("=")(.*)/;
$LineKey=$0;
$LineValue=$2;
# say "LineKey = <$LineKey> LineValue = <$LineValue>";
for %x.kv -> $key, $value {
# say " key = <$key> value = <$value>";
if ( $LineKey eq $key ) {
%x<$key> => $LineValue;
say "LineKey = <$LineKey> key = <$key> LineValue = <$LineValue> value = <$value>";
}
}
}
say %x;
</code>
HashLoopTest.pl6
[a=A b=B c=C]
{a => , b => , c => }
LineKey = <a> key = <a> LineValue = <A> value = <>
LineKey = <b> key = <b> LineValue = <B> value = <>
LineKey = <c> key = <c> LineValue = <C> value = <>
{$key => 「C」, a => , b => , c => }