develooper Front page | perl.libwww | Postings from April 2001

RE: How do I build a associative array from a dyanamic list

Thread Previous | Thread Next
From:
Ben Goswami
Date:
April 11, 2001 12:16
Subject:
RE: How do I build a associative array from a dyanamic list
Message ID:
006f01c0c2bb$ddc5e220$9d14a8c0@BENG
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                                      |
\===============================================================/





Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About