The root can have more many pages, and each page can have many fields. The fields only have the ID and value. I am trying to add a new field to a specific page. So far I have got:<root> <page> <field> <ID></ID> <value></value> </field> </page> </root>
when dumped this produces:my $pageobj=$data->{page}[$pagenumber]; my $fieldobj=$pageobj->{field};
I have tried various ways of adding a new field to this, I would ideally like to build a new field from values I enter, and then add it to the array. I tried creating a new hash, and adding in a value and ID. Although I feel I am slipping up somewhere:[ { 'value' => [ 'test' ], 'ID' => [ '0000001' ] }, { 'value' => [ 'test' ], 'ID' => [ '0000002' ] }, { 'value' => [ 'test' ], 'ID' => [ '0000003' ] }, { 'value' => [ 'test' ], 'ID' => [ '0000004' ] } ]
After dumping this, it doesnt seem to have the desired result... Any help would be amazing TienLungmy $pageobj=$data->{page}[$pagenumber]; my $fieldobj=$pageobj->{field}; my %tmpF=(); my @tmpA; push(@tmpA,"0001"); %tmpF->{ID}=@tmpA; push(@$fieldobj,%tmpF);
In reply to Arrays and Hashes woes by TienLung
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |