more useful options | |
PerlMonks |
Layman's terms how-to on HoH refs and the arrow operatorby snafu (Chaplain) |
on Dec 27, 2002 at 05:34 UTC ( [id://222479]=perlquestion: print w/replies, xml ) | Need Help?? |
snafu has asked for the wisdom of the Perl Monks concerning the following question:
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:
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> Note that $array[$x] is NOT the same thing as $array->[$x ]here: The arrow is optional BETWEEN brackets subscripts, so you can shrink the above down to </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:
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.
_
_
_
_
_
_
_
_
_
_
update (broquaint): title change (was Lamens terms how-to on HoH refs and the arrow operator)
Back to
Seekers of Perl Wisdom
|
|