use Data::Dumper;
my @array;
push @array, {'key1' => 'value1', 'key2' => 'value2'};
push @array, {'key1' => 'value1', 'key2' => 'value2'};
push @array, {'key1' => 'value1', 'key2' => 'value2'};
print Dumper(@array);
Will give you:
$VAR1 = {
'key2' => 'value2',
'key1' => 'value1'
};
$VAR2 = {
'key2' => 'value2',
'key1' => 'value1'
};
$VAR3 = {
'key2' => 'value2',
'key1' => 'value1'
};
Snazzy!
Did you find this post useful or have questions or comments? Please let me know!
1 response so far ↓
1 mikerochford.com » Howto push a hash onto an array // May 27, 2009 at 9:00 am
[...] 2009 mrochford Leave a comment Go to comments This information was giving to me by my friend Matt use Data::Dumper; my @array; push @array, {’key1′ => ‘value1′, [...]
Leave a Comment