$a = {b=>{c=>1}}; # set up ref
$b = $a->{b}; # ref the ref
$b .= (d=>1,e=>1); # where we want to assign multiple key/val at once
At the end of it $a
should look like:
{ 'b' => { 'c' => 1, 'd' => 1, 'e' => 1 } };
At the end of it $b
should look like:
{ 'c' => 1, 'd' => 1, 'e' => 1 }
Note: it would be the same as doing:
$b->{d} = 1;
$b->{e} = 1;
$b = { %$b, d=>1, e=>1 };
Is not desired because it creates a copy of $a
and loses the reference.
%{$b} = ( %{$b}, d => 1, e => 1 );
worked (that it still applied changes to the referenced$a
) – Kansu