I agree with simply operating on the refs in-place. On the other hand, functional style is
is good, and if you don't want to modify the input hashes, you can still have an elegant call/return by using refs throughout the code:
my $x = {"a" => "red"};
my $y = {"b" => "green"};
my $z = {"c" => "black"};
my ($new_x, $new_y, $new_z) = &modfifyHash($x, $y, $z);
# original $x is unchanged, $new_x has new value
print "\$x->{a} = $x->{a}\t\$new_x->{a} = $new_x->{a}\n";
sub modfifyHash {
my ($x, $y, $z) = @_;
# If we don't want to modify the originals,
# then make a shallow copy for each
$_ = { %$_ } for $x,$y,$z;
$x->{ "a" } = "circle";
$y->{ "b" } = "square";
$z->{ "c" } = "rectangle";
return($x, $y, $z)
}