Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Also bear in mind that the way in which Perl is actually doing this, explicitly or implicitly, is through the magic of references.   The value associated with a particular hash-key, like a particular element in an array, is always “a single scalar,” but ... a reference is “a single scalar,” no matter what it refers to.   That is the secret to creating arbitrary data-structures in Perl.   The memory-manager allows an arbitrary number of references to exist to the same piece of data and maintains a reference-count for each piece, automatically disposing of no-longer-referenced pieces.

So, Perl’s technically-correct view of your title line would be:   “inserting a reference to an array, into one of the hashes which are referenced by:   an array, whose elements happen to entirely consist of:   references to hashes.”

Self-evident:   hashref is slang for “reference to a hash;” arrayref is slang for “reference to an array.”

Perl is a very forgiving language that encourages “say what I mean,” allowing you to say the same thing in several different ways ... but it is important to bear in mind that this is how all those ways of saying it wind up.   References are one of the “cornerstone ideas” of this language.


In reply to Re: Inserting an array in an array of hashes by sundialsvc4
in thread Inserting an array in an array of hashes by gibsonca

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, 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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [LanX]: ... thank God France doesn't have an electoral college...
    [Eily]: LanX, let's hope it gets better for the second turn
    vrk adds oatmeal cookies to the platter on the sideboard.
    [LanX]: evrybody can participate in a YAPC
    choroba is still undecided what to present at YAPC
    [LanX]: imagine the stock market if the choice for the second round would have been those two ...
    [robby_dobby]: LanX: Not me. No YAPC in my country and the only one in Asia is so far off in Japan
    [LanX]: Oh I thought "Misery" meant Missoury
    [LanX]: where do you live?
    [LanX]: YAPC Asia was renamed and you'd need to speak Japanese to be able to follow

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (12)
    As of 2017-04-24 15:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I'm a fool:











      Results (442 votes). Check out past polls.