I was reading the docs for Finance::Quote and saw some weird syntax described as "two-dimensional hashes." I thought, "That must just be a hash of hashes," and, "I had no idea that syntax would work." Messing around with it I immediately discovered it wasn't an alternative syntax but an entirely different key construction.

In 10 years of Perl I've never seen this and I realize I might be naïve but does anyone have an overview or insight into this? Is this what they're usually called? Are these used in the wild? How long have they been available? Are they in a major document that I've failed to FR?

DB<15>use Finance::Quote; DB<16>$q = Finance::Quote->new; DB<17>%quotes = $q->fetch("nasdaq","lway"); DB<18> use YAML; DB<19> print Dump \%quotes --- "LWAY\x1cask": ~ "LWAY\x1cavg_vol": 19988 "LWAY\x1cbid": 9.05 "LWAY\x1ccap": 208.6M "LWAY\x1cclose": 12.55 "LWAY\x1ccurrency": USD "LWAY\x1cdate": 06/19/2009 "LWAY\x1cday_range": '12.2901 - 12.75' "LWAY\x1cdiv": 0.00 "LWAY\x1cdiv_date": ~ "LWAY\x1cdiv_yield": ~ "LWAY\x1ceps": 0.153 "LWAY\x1cex_div": ' 9-Mar-04' "LWAY\x1chigh": 12.75 "LWAY\x1cisodate": 2009-06-19 "LWAY\x1clast": 12.40 "LWAY\x1clow": 12.2901 "LWAY\x1cname": 'Lifeway Foods, In' "LWAY\x1cnet": -0.15 "LWAY\x1copen": 12.66 "LWAY\x1cp_change": -1.20 "LWAY\x1cpe": 82.03 "LWAY\x1cprice": 12.40 "LWAY\x1csuccess": 1 "LWAY\x1csymbol": LWAY "LWAY\x1ctime": 16:00 "LWAY\x1cvolume": 29649 "LWAY\x1cyear_range": '5.43 - 15.48' DB<20> print $quotes{"LWAY","open"} 12.66 DB<23> $asdf{qw(one two three )} = "OH HAI"; DB<24> print $asdf{"one","two","three"} OH HAI


In reply to Um... WTF? Multi-dimensional hashes by Your Mother

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.