RE: How do I build a associative array from a dyanamic list
Ben Goswami (ben.goswami@infospace.com)
Wed, 11 Apr 2001 12:16:09 -0700
Thanks, but I still have not the answer. my question is :
here is the data source which is an xml:
<response>
<cart>
<item><id> = 11</item>
<item>id = 12</item>
<item>id = 13</item>
</cart>
<shipping></shipping>
</response>
I've to build an nested assoicative array
(like: %response = ( cart-> { item1 => 11,
item2 = 12,
item3 = 13},
shipping -> ...
);
from this xmls after parsing. but the number of items are not fixed. Even
though I know how many items are there before building the associative array
as I cannot put it thru a loop and keep 'adding' to the associative array
because
ASSOCIATIVE ARRAY DOES NOT SUPPORT THE 'ADD' OR 'PUSH' FUNCTION LIKE REGULAR
ARRAY.
any idea how to solve this
thx
-----Original Message-----
From: francis@localhost.localdomain
[mailto:francis@localhost.localdomain]On Behalf Of John Stracke
Sent: Wednesday, April 11, 2001 12:04 PM
To: libwww@perl.org
Subject: Re: How do I build a associative array from a dyanamic list
"Michael A. Chase" wrote:
> $hash{'a'}{'b'} = "value in b of a";
That should be $hash{'a'}->{'b'}. A hash cannot contain other hashes, it
can
only contain scalars (such as references).
--
/===============================================================\
|John Stracke | http://www.ecal.com |My opinions are my own. |
|Chief Scientist |==============================================|
|eCal Corp. |*BOOM* "Thank you, Beaker. Now we know that is|
|francis@ecal.com|definitely too much gunpowder." -- Dr. Bunsen |
| |Honeydew |
\===============================================================/