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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pushing a hash to an array 1

Status
Not open for further replies.

1DMF

Programmer
Joined
Jan 18, 2005
Messages
8,795
Location
GB
how do I create a hash on the line I use push.

i.e.
Code:
push @array, "key->value,key->value";

i want @array to have an index which holds a hash, key = 'a_name' value = 'January', key = 'text' value='January'

hope this makes sense.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
You have to use a hash reference (which are enclosed in curly brackets), i.e.:
Code:
push @array, { key1 => 'value', key2 => 'value' };
 
spot on , thanks ishnid, a gent as always!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top