I have an array like so:
@switch_ports = ()
and then want to add 50 instances of this hash, to the switch_ports array.
%port = (data1 => 0, data2 => 0, changed => 0)
However, if I push my hash to the array:
push(@switch_ports, %port)
and I do print @switch_ports, I just see:
data10data20changed0
so it just seems to be adding them to the array, (joining them) and if I try and loop the array and print the keys, it also fails.
Can you store a hash in an array?
Can you have an array of hashes?
I'm trying to get this:
switchports
0
data1
data2
changed
1
data1
....
thus:
foreach $port (@switchport) {
print $port['data1']
}
would return all of the data1 for all of the hashes in the array.