Well, I figured out that the problem was not suited
for a multi-dimensional hash, but rather just a hash. 
And I didn't know that hashes flattened out like
arrays when one is stored within another.  References
are actually next on my list, but I've still a bit to
go with hashes.  Thanks for all the advice so far.
-stu


 
--- "R. Joseph Newton" <[EMAIL PROTECTED]> wrote:
> Stuart White wrote:
> 
> > I've a problem that I think is best solved with
> > multi-dimensional hashes.  However, the reference
> that
> > I'm using doesn't really cover them.  Does anyone
> know
> > where I might find some tutorial article of some
> sort
> > with an example or two on multi-dimensional
> hashes?
> >
> > I know that the syntax for referring to an element
> > within the inner hash is:
> > $hash1[$hash2[$hash2key]]
> 
> Careful about "knowing" things, Stuart.  It is
> hanging you up.
> There are no multidimensional hashes in the sense
> that you are
> trying to use them.  Please stop wasting your time
> on that tack, and
> put your energy into the more productive path of
> learning
> references.  Only the outer hash in a
> multidimensional hash can be a
> hash itself.  Hashes can not be stored inside of
> either arrays or
> other hashes.  That is a dead end.
> 
> OTOH, *references to hashes* can be stored anywhere
> a scalar can,
> which means that you can build multidimesional hash
> structures to
> depths limited only by the resources of your
> computer.
> 
> Given that you will be using references throughout
> the internal
> structure of your hash, you may as well start out
> with a reference:
> my $md_hash_base = {};  # $md_hash_base is now a
> reference to the
> anonymous hash on the right.
> $md_hash_base->{'kid'} = {}; # first generation
> $md_hash_base->{'kid'}->{'grandkid'} = {};
> $md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'} = {name =>
> 'Humphrey', birthweight => '3.82 KG'};
> print "$md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'}->{'birthweight'}\n";
> my $little_un =
> $md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'};
> print "$little_un->{'name'}\n";
> 
> 
> Joseph
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to