TienLung has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Arrays and Hashes woes
by moritz (Cardinal) on Mar 16, 2009 at 11:07 UTC | |
by TienLung (Acolyte) on Mar 16, 2009 at 11:27 UTC | |
|
Re: Arrays and Hashes woes
by almut (Canon) on Mar 16, 2009 at 11:05 UTC | |
by TienLung (Acolyte) on Mar 16, 2009 at 11:30 UTC | |
by almut (Canon) on Mar 16, 2009 at 11:56 UTC | |
|
Re: Arrays and Hashes woes
by Jenda (Abbot) on Mar 16, 2009 at 18:28 UTC | |
|
Re: Arrays and Hashes woes
by locked_user sundialsvc4 (Abbot) on Mar 16, 2009 at 16:27 UTC |