Yeah, I thought that %{ _ref_ } created an alias, but now I've learned it just shallow copies the struct.

It's coincidental, but everytime I used it as reference passed to subs, I added subkeys and everything worked as an alias. To my surprise, when I added a root key to %copy and it didn't change %hash my world came tumbling down.

So it's back to $$copy->{key} stuff, as

use strict; local our %copy; *copy = \%hash;

Looks so unscoped to my personal perl taste. And Data::Alias will not cpan into my Strawberry perl, complaining about requiring perl 5.8.9 on Win32...

BTW ikegami, wow!

Now... I want to know what package does those hash textgraphs you posted. Cos Data::Dumper doesn't get even close to that kind of representation!


In reply to Re: Shallow vs deep copy (Was Re^3: hash ref mind blow) by Anonymous Monk
in thread hash ref mind blow 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.