Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ho can I add values to Hash at runtime?

Status
Not open for further replies.

Bhavani2007

Programmer
Jul 24, 2007
5
IN
Hi,

I have to set some values based on some conditions to hash object at runtime
How can i set?
I am using the following code.
if($attrs{"CollType"} eq "A")
{
%A_hash = ($attrs{"State"},$attrs{"Team"});
}
I am parsing one xml file and based on the CollType I am assigning the state and team values to A hash.
But finally i get the last key value only.and its size is always 1.
Hash is not growing as needed.
How can i achieve this?

Thanks in advance.

Regards,
Bhavani
 
That code you're using defines the entire contents of the hash, rather than attempting to add to the existing contents. Try this:
Code:
$A_hash{ $attrs{State} } = $attrs{Team};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top