... extract an individual's record ... and assign it to a hash [to send] to a subroutine for processing ... "extract hash from hash of hashes and assign it to its own hash" ... retrieve an individual record ...

These invocations of 'individuality' lead to a sneaking suspicion of the notion of isolation.

The thing to remember about Perl complex data structures is that below the top-most level, it's references all the way down. And, of course, "a reference does what a reference do".

In other words, the copy operations bdalzell shows in the OP (or should that be the OM: Original Meditation?) are 'shallow' copies: all the references involved still go trailing back to their original referents. (An example of this shown below.) Given this is the case, I find it is usually easier and less potentially self-deceptive to simply extract and pass around the references themselves rather than trying to make 'copies' of them.

>perl -wMstrict -le "use Data::Dumper; ;; my %HoH = ( foo => { bar => { baz => { quux => 42, }, }, }, ); print Dumper \%HoH; ;; my %my_own_bar = %{ $HoH{foo}{bar} }; $my_own_bar{baz}{quux} = 'OOPS'; print Dumper \%my_own_bar; print Dumper \%HoH; " $VAR1 = { 'foo' => { 'bar' => { 'baz' => { 'quux' => 42 } } } }; $VAR1 = { 'baz' => { 'quux' => 'OOPS' } }; $VAR1 = { 'foo' => { 'bar' => { 'baz' => { 'quux' => 'OOPS' } } } };

You have been warned.


In reply to Re: RFC How to retrieve a hash from a hash of hashes by AnomalousMonk
in thread RFC How to retrieve a hash from a hash of hashes by bdalzell

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.