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;
In reply to hashes, arrays, and references... oh my by regan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |