NetWallah, I think there is no difference between your's and mine.
#!/usr/bin/perl use strict; use Data::Dumper; my @AoH = ({ title => 'aaa', heading => [ {item => 'bbb'}, {item => 'ccc'}, {item => 'ddd'}, ]}); #$AoH[0]->{heading}->[3] = {item => 'eee'}; #your's $AoH[0]->{heading}->[3]->{item} = 'eee';#mine #print $AoH[0]->{title}; #print $AoH[0]->{heading}->[0]->{item}; #print $AoH[0]->{heading}->[1]->{item}; #print $AoH[0]->{heading}->[2]->{item}; #print $AoH[0]->{heading}->[3]->{item}; print Dumper @AoH;
your output:
$VAR1 = { 'heading' => [ { 'item' => 'bbb' }, { 'item' => 'ccc' }, { 'item' => 'ddd' }, { 'item' => 'eee' } ], 'title' => 'aaa' };
my output:
$VAR1 = { 'heading' => [ { 'item' => 'bbb' }, { 'item' => 'ccc' }, { 'item' => 'ddd' }, { 'item' => 'eee' } ], 'title' => 'aaa' };
Prasad
In reply to Re^2: adding an element to AoH
by prasadbabu
in thread adding an element to AoH
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |