In hv.c is written, that keys (hek-structure) are shared for space optimization. But i don't find any example for that. If i use this hashes $rgb{rot}='aaa ';$cmyk{rot}='aaa'. Is the key 'rot' shared between them? If i look in the output of:
perl -MDevel::Peek -e '$rgb{rot}="aaa";$cmyk{rot}="aaa";Dump(\%rgb);Du +mp(\%cmyk)'
I don't see any shared keys:
SV = RV(0x1351ba8) at 0x1351b98 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x136ecf0 SV = PVHV(0x1357fb0) at 0x136ecf0 REFCNT = 2 FLAGS = (SHAREKEYS) ARRAY = 0x1392a30 (0:7, 1:1) hash quality = 100.0% KEYS = 1 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "rot" HASH = 0xaffb6cf6 SV = PV(0x134fb78) at 0x1351d48 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x1369340 "aaa"\0 CUR = 3 LEN = 8 SV = RV(0x1351ba8) at 0x1351b98 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x1378990 SV = PVHV(0x1357fd8) at 0x1378990 REFCNT = 2 FLAGS = (SHAREKEYS) ARRAY = 0x1368fa0 (0:7, 1:1) hash quality = 100.0% KEYS = 1 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "rot" HASH = 0xaffb6cf6 SV = PV(0x134fc58) at 0x1351f88 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x13652c0 "aaa"\0 CUR = 3 LEN = 8

In reply to When will a key shared between two hashes? by gyhor

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.