sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:
I read a few tutorials online, LP3 doesn't seem to mention it and the Perl Cookbook has a small section on it I've read but I have a few questions.
Is an anonymous hash also known as a multi-dimensional hash where you can literally have different hashes inside of a single hash?
The problem I am trying to get through is creating a mess of hashes on the fly and add records to them without having to create 150 or so different hash names.
An example of what I am trying to do would be a set of hashes for each meta tag (see below). This would be for EACH meta tag. Now in the real world, I don't want to manually create a hash for each possible meta tag.
Real example:Meta tag name Meta tag value Meta tag character count Meta tag word count Meta tag word repeat count
This isn't what I'm really trying to do with it but this seemed to be the best way to explain what I am trying to do. I have hundreds of separate hashes I need to create dynamically and store values into and someone mentioned anonymous hashes and arrays are the way to go.Title Welcome to my website! 22 4 1 Keywords candy, food, pop, candy cane, soda, caffeine 31 5 2
An example from http://search.cpan.org/~nwclark/perl-5.8.5/pod/perlref.pod:
This doesn't look like anything more than single key/value pairs and I don't see examples on how to do what this script requires.$hashref = { 'Adam' => 'Eve', 'Clyde' => 'Bonnie', };
How practical are anonymous hashes and arrays? This is the first time I've ever had to do them and it's because I need dynamic hashes created without needing to create new hashes. Is the primary use for these to create arrays or hashes dynamically?
Thanks for your help wise monks.
"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"
sulfericacid
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Introduction to anonymous arrays and hashes
by demerphq (Chancellor) on Nov 06, 2004 at 10:44 UTC | |
Re: Introduction to anonymous arrays and hashes
by Zaxo (Archbishop) on Nov 06, 2004 at 08:35 UTC | |
Re: Introduction to anonymous arrays and hashes
by Aighearach (Initiate) on Nov 06, 2004 at 07:55 UTC | |
Re: Introduction to anonymous arrays and hashes
by pg (Canon) on Nov 06, 2004 at 08:24 UTC | |
Re: Introduction to anonymous arrays and hashes
by Prior Nacre V (Hermit) on Nov 06, 2004 at 10:19 UTC | |
Re: Introduction to anonymous arrays and hashes
by dimar (Curate) on Nov 06, 2004 at 17:58 UTC | |
by redspike (Initiate) on Aug 29, 2009 at 23:03 UTC | |
Re: Introduction to anonymous arrays and hashes
by bobf (Monsignor) on Nov 06, 2004 at 21:22 UTC | |
Re: Introduction to anonymous arrays and hashes
by TedPride (Priest) on Nov 06, 2004 at 12:16 UTC |