When you copy the hash with my %hash = @_; you are making copies of its values, but those values are themselves references. And the copied references refer to the same things that the originals do!
In order to get pass-by-value like behavior¹ with complex structures in Perl, you need to make a "clone" or "deep copy" of your structures. The Storable module can help with that.
1. I say "pass-by-value like behavior" because, regardless, the actual passing to your subs is really by reference. You must make the copy yourself.
"My two cents aren't worth a dime.";