OK. I've been readin documentation on this and other sites and I have to admit that I am *very* frustrated with my lack of understanding to this point.

I know that there are many out there who try and read the documentation provided and find the documentation is written with so much high speak that there are those of us who don't 100% understand what they are reading. I am one of those people right now.

So, with that let me explain what I need to wrap my brain around and I sincerely hope that there is someone here who will be kind enough to explain in lamans terms the explanation. I have been working on a project that uses an HoH. Now, I know that you can reference an HoH the following way:

$hash{key}; # single dimension hash $hash{key1}{key2}; # multiple dimension hash

I understand this full-well. Ok, so what I would like to do is figure out what the heck the arrow operator does as according to the manual using the arrow operator is *not* the same as not using it (but then quickly turns around and seems to contradict itself saying that the arrow operatoris optional to use.

<quote>

Subroutine calls and lookups of individual array elements arise often +enough that it gets cumbersome to use method 2. As a form of syntactic sugar, the examples + for method 2 may be written: $arrayref->[0] = "January"; # Array element $hashref->{"KEY"} = "VALUE"; # Hash element $coderef->(1,2,3); # Subroutine call The left side of the arrow can be any expression returning a reference, including a previous dereference.
Note that $array[$x] is NOT the same thing as $array->[$x ]here:
$array[$x]->{"foo"}->[0] = "January"; This is one of the cases we mentioned earlier in which references coul +d spring into existence when in an lvalue context. Before this statement, $array[$x] +may have been undefined. If so, it's automatically defined with a hash reference so +that we can look up {"foo"}in it. Likewise $array[$x]->{"foo"}will automatically g +et defined with an array reference so that we can look up [0]in it. One more thing here.
The arrow is optional BETWEEN brackets subscripts, so you can shrink the above down to
$array[$x]{"foo"}[0] = "January"; Which, in the degenerate case of using only ordinary arrays, gives you + multidimensional arrays just like C's: $score[$x][$y][$z] += 42; Well, okay, not entirely like C's arrays, actually. C doesn't know how to grow its arrays on demand. Perl does.
</quote>

So what the freak does the arrow operator do!?!?! Because I just get confused from this documentation :). Now, Let me give you folks a little more of a view into the application that I am working on.

I have a reference to an HoH which has the structure:

$$player_dbref{player_name}{ip}{user_id};

Now I find myself in the most awkward position of wanting to add a new dimension to the hash (yes that was sarcasm). Now right now I need to actually reference the hash keys with the actual values IE $$player_dbref{happyplayer}{22.22.22.22} which would yield 265 (the player id), right? But what I decided would be easier is to actually have the hash be unique based off the first key in the hash (as usual) then to be able to reference the rest of the keys below that player key by using a topical key. Ok, so that didn't make sense so let me illustrate:

So usually I'd use $$player_dbref{happyplayer}{22.22.22.22} to get the user id and to get that I'd have to traverse the hash keys to find the name of a player and then I'd have to traverse the hash again with the player's name I just got as the key to get the IP and so on and so forth.
Is there a way to only traverse the hash keys the one time for the player name and then use the topical references such as:$$player_dbref{player_name}{ip_addr} for the player's IP and $$player_dbref{player_name}{ip_addr}{id} to get the user id where you are actually using the words 'ip_addr' and 'id' as topical references of what you want in the hash keying off the player name? Does this make sense?? :) Is this what arrow operator is for?!?! If I am right in the way I am doing it and there is no other way to do it then I will just continue doing what I am doing but if there is an easier way I'd LOVE to know what it is.

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...

update (broquaint): title change (was Lamens terms how-to on HoH refs and the arrow operator)


In reply to Layman's terms how-to on HoH refs and the arrow operator by snafu

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.