>
> temp %h;
> %h{ %other.keys } = %other.values;
>
> or even
>
> temp %h{ %other.keys } = %other.values;
>
> should work well already?
Almost - but not quite.
In Perl5
perl -MData::Dumper -e '%h=qw(a 1 b 2); {local %h; $h{a}="one"; print Dumper
\%h} print Dumper \%h;
$VAR1 = {
'a' => 'one'
};
$VAR1 = {
'a' => '1',
'b' => '2'
};
I'm imaging the behavior would be the same with Perl6. Notice that 'b' is
gone in the first print. I only want to temporarily modify "some" values
(the ones from the %other hash). I don't want the contents of the %h to be
identical to %other - I already have %other.
So in Perl5 this does work:
perl -MData::Dumper -e '%h=qw(a 1 b 2); {local %h=%h; $h{a}="one"; print
Dumper \%h} print Dumper \%h;
$VAR1 = {
'a' => 'one'
'b' => '2',
};
$VAR1 = {
'a' => '1',
'b' => '2'
};
But this won't work in Perl6 (temp $var = $var doesn't work in Perl6) and
again it may be fine for small hashes with only a little data - but for a
huge hash (1000+ keys) it is very inefficient.
This is good discussion - but it isn't the real focus of the original message
in the thread - the question is about the local (temp) scoping of looping
statement modifiers in Perl6.
Though, I do appreciate your trying to get my example working as is.
Paul