robbiebow has asked for the wisdom of the Perl Monks concerning the following question:
Wise ones, I seek assistance!
Having returned to PERL after not long enough on glorious beaches, I'm floundering with a nested array of hashes. I'll try to explain:
I have a pipe-delimited text file, each line representing a 'Category'. Within each Category is a number of Items, each with a description and reference number. Here's an example:
'Coffee Suppliers','BB100'|'Tea Suppliers','BB106'I also have another file with the Category descriptions in. For example:
'BB','Drinks Industry'What I want to do is:
(a) reverse the order of first set of records so that the reference is first, then the description (so I can use these as hashes / associative arrays when I read the data normally); and
(b) merge the two sets with the second set of data being popped onto the beginning of each category array.
(As you have guessed, the first two characters of the Item reference are the same as the Category reference.)
The outcome would be:
'BB','Drinks Industry'|'BB100','Coffee Suppliers'|'BB106','Tea Suppliers'Any advice gratefully received.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multidimensional array of hashes
by broquaint (Abbot) on Oct 03, 2003 at 12:03 UTC | |
|
Re: Multidimensional array of hashes
by Roger (Parson) on Oct 03, 2003 at 11:54 UTC | |
|
Re: Multidimensional array of hashes
by jonadab (Parson) on Oct 03, 2003 at 12:53 UTC | |
|
Re: Multidimensional array of hashes
by Rhys (Pilgrim) on Oct 03, 2003 at 13:29 UTC | |
|
Re: Multidimensional array of hashes
by bm (Hermit) on Oct 03, 2003 at 11:55 UTC |