Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
This does not affect the real %hash. By de-referencing it like that, you're essentially creating a copy. The item on the right-hand-side is now a real hash (by virtue of wrapping it in %{...}), not a reference. Thus, you are effectively doing this:
%hash1 = %hash2;
This does not create an alias, but a copy. Changes to %hash1 have no effect on %hash2.

And no, you don't have to put parens around your split call. Perl does the correct thing here, but it may be more readable to others if you write it with parens anyway. Here is some test-case code you can try yourself:

sub test { my $hash1 = shift; my %hash2 = %{shift}; $hash1->{three} = 3; $hash2{three} = 3; } my %a = (one => 1, two => 2); my %b = (one => 1, two => 2); &test(\%a, \%b); print join(", ", keys %a), "\n"; print join(", ", keys %b), "\n"; # three, two, one # two, one

In reply to RE: Answer: how do I use a hash of hashes reference to a function ? by Fastolfe
in thread how do I use a hash of hashes reference to a function ? by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (5)
    As of 2020-10-31 07:23 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (287 votes). Check out past polls.