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) }

In reply to Re: Elegantly dereferencing multiple references by Yary
in thread Elegantly dereferencing multiple references by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.