![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Re: parsing a config fileby arturo (Vicar) |
on May 21, 2003 at 18:53 UTC ( #259836=note: print w/replies, xml ) | Need Help?? |
The following is untested; it's also not uber-leet, but then what do I care about that? =)
What this does is put each configuration entry, stored as a hash reference, into an array. If you just want to print the darn thing out, you could print out the hash instead of push ing an anonymous copy (which is what the { %conf } syntax does) onto the array. What this code gives you is an array, each of whose members corresponds to one of the "QueueManager" entries (where that means, "follows a QueueManager line and ends at a new QueueManager line or the end of the file, whichever comes first). Managing to do something with this data structure, or changing it to a diffferent kind of structure (it strikes me that what you'd really like if you're using this as a config file is a hash of hashes, where the key of each hash is the name of the queue manager, and whose values are the other values.) is something I'll let you figure out for yourself, with a tip of the hat to References quick reference, perlref, perllol, and perldsc. HTH and good luck! If not P, what? Q maybe?
In Section
Seekers of Perl Wisdom
|
|