This makes a (shallow) copy of %hashVal :
my %hashDeref = %{$hashRef};
hash-ref $hashRef still points to %hashVal , but %hashDeref not, it's just a copy. If you want to change the passed hash-ref in place, then work with the passed hash-ref:
sub checkHashRef{ my ($hashRef, $arrVal) = @_; $hashRef->{'check'} = 2;
This will leave your changes to %hashVal . In the case of an array, you never make a copy, you just play it in place:
push(@{$arrVal}, 3);
and the change to $arrVal displayed in @arrVal .
mu is too short
source share