regan has asked for the wisdom of the Perl Monks concerning the following question:
I do things like: ...<ObjectType> <AppObject>hello</AppObject> <AppObjectField>gender</AppObjectField> <valueTargetPair value="MALE" targetPo="Incoming 1" /> <valueTargetPair value="FEMALE" targetPo="Incoming 2" /> </ObjectType>
... no problem. my problem is the more complicated <valueTargetPair> tag. I parse the values for the value and target labels into $1 and $2. I want to put these two things into a hash with two entries, having value and targetPo as the keys. Now, because I have several valueTargetPair tags, I need to put this has into an array! I do all of that like this:}elsif ($_ =~ /<AppObjectField>(.*)<\/AppObjectField>/) { $self->{appObjFld} = $1; }
then, to keep it in my $self object, I do something like:if ($inline =~ /<valueTargetPair (.*)\/>/) { if ($inline =~ /value=\"(.*?)\" targetPo=\"(.*?)\"/) { my %theHash = {value=>$1, targetPo=>$2}; push (@arry, \%theHash); } }
To summarize, I parse some xml (not really important that it is xml), and put some of the results into a hash. I store the hashes in an array, which I then need to store in another hash! This leaves me with a hash holding an array holding hashes. I think that the above is all okish My problem, is that later on, I run a method to print out the contents. pulling the simple values (like $self->{appObjFld} ) out of the $self hash is easy. getting that value Pair stuff out is murder. How can I pull out the original %theHash, so that I can print each valueTargetPair?$self->{valuePair} = \@arry;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: references, hashes, and arrays.. oh MY!!
by dragonchild (Archbishop) on Aug 05, 2003 at 20:39 UTC | |
|
Re: HoAoH
by tadman (Prior) on Aug 05, 2003 at 20:43 UTC | |
by regan (Sexton) on Aug 05, 2003 at 21:10 UTC | |
by jeffa (Bishop) on Aug 05, 2003 at 21:29 UTC | |
by regan (Sexton) on Aug 05, 2003 at 23:51 UTC | |
|
Re: hashes, arrays, and references... oh my
by graff (Chancellor) on Aug 06, 2003 at 01:46 UTC | |
|
Re: hashes, arrays, and references... oh my
by eric256 (Parson) on Aug 05, 2003 at 21:23 UTC |