M
Me
How do I add element to array which is a hash element?
So far I have:
====================
push ($data{"ny"}{list}, { dat=>2});
push ($data{"ny"}{list}, { dat=>5});
push ($data{"dc"}{list}, { dat=>9});
====================
which generatees the following:
====================
Type of arg 1 to push must be array (not hash element) at hash.pl line
1, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line
2, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line
3, near "})"
=====================
I want to end up with something like:
data =>
{
location => "ny"
list = [
{dat=>2},
{dat=>5}
]
},
location => "dc"
list = [
{dat=>9},
]
},
So far I have:
====================
push ($data{"ny"}{list}, { dat=>2});
push ($data{"ny"}{list}, { dat=>5});
push ($data{"dc"}{list}, { dat=>9});
====================
which generatees the following:
====================
Type of arg 1 to push must be array (not hash element) at hash.pl line
1, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line
2, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line
3, near "})"
=====================
I want to end up with something like:
data =>
{
location => "ny"
list = [
{dat=>2},
{dat=>5}
]
},
location => "dc"
list = [
{dat=>9},
]
},