develooper Front page | perl.beginners | Postings from December 2002

RE: Dynamic Array Names

Thread Previous | Thread Next
Mark Anderson
December 10, 2002 12:55
RE: Dynamic Array Names
Message ID:

> I have an array that I want to generate a new hash for each item that is
> the first array. I want the new hashes to be named as the 1st array. Wow
> I am confused reading that. Example ...

Yes it is.

> I am using Config::IniFiles

I haven't used it, so I can't give you any module specific help.

> I place all the sections from the ini file into an array. I then want a
> new hash for each section that contains all the values and keys for that
> section.

Sounds good.

> Ini
> -=-
> [Kelly]
> machine=kluiere;
> username=backup;
> password=systems;
> email=xp;
> share=c$;
> path=\Documents and Settings\kelly\My Documents\;
> So I would have an array that would contain the name kelly. I then want
> to produce a hash called kelly that would contain.
> Machine=>kluirere ... For each item.

No you don't.  Sorry.  Someone else hopefully will post the link to the
column that someone wrote that would tell you why.

What you do want to have is a single hash (I'm going to call it %iniHash).
You want it to have keys to each section from your ini, and each of those
will have a value that is a hash with the keys being the ini key/value
pairs, so the above would look like:


You then don't actually need to create the array, unless the order from the
ini file is important because the keys (perldoc -f keys) function will
produce that array for you (in 'random' order).

Hope this helps, don't hesitate to ask for clarification.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About