It is not completely clear to me what output you are trying to achieve (a small sample of the output you expect would make it clear), but perhaps a different approach using a different module (XML::Twig) could help you to avoid this problem. I realize this does not directly answer your XML::Simple question, but it is something you could consider.
use strict; use warnings; use XML::Twig; use Data::Dumper; my $xmlStr = <<XML; <project by="company" name="personname"> <pattern name="company-000001" owner="company" description="Microarr +ay" species_database="d.base"> <reporter name="A_24_P344666" systematic_name="NM_020341"> <feature number="1780"> <position x="0.733234841870825" y="10.033" units="mm" /> </feature> <gene systematic_name="NM_020341" primary_name="PAK7" descriptio +n="Homo sapiens p21(CDKN1A)-activated kinase 7 (PAK7), transcript var +iant 1, mRNA [NM_020341]"> <accession database="ref" id="NM_020341" /> <accession database="ref" id="NM_177990" /> <accession database="ens" id="ENST00000378429" /> <accession database="ens" id="ENST00000378423" /> <other name="accessions" value="ref|NM_020341|ref|NM_177990|en +s|ENST00000378429|ens|ENST00000378423" /> <other name="chr_coord" value="chr20:9466136-9466077" /> </gene> </reporter> <reporter name="foo" systematic_name="boo"> <feature number="1780"> <position x="0.733234841870825" y="10.033" units="mm" /> </feature> <gene systematic_name="boo" primary_name="goo" description="Homo + sapiens p21(CDKN1A)-activated kinase 7 (PAK7), transcript variant 1, + mRNA [NM_020341]"> <accession database="ref" id="NM_020341" /> <accession database="ref" id="NM_177990" /> <accession database="ens" id="ENST00000378429" /> <accession database="ens" id="ENST00000378423" /> <other name="accessions" value="ref|NM_020341|ref|NM_177990|en +s|ENST00000378429|ens|ENST00000378423" /> <other name="chr_coord" value="chr20:9466136-9466077" /> </gene> </reporter> </pattern> </project> XML my %data; my $twig= new XML::Twig( twig_handlers => { reporter => \&reporter } ); $twig->parse($xmlStr); print Dumper(\%data); exit; sub reporter { my ($twig, $rep) = @_; my $name = $rep->att('name'); my $sname = $rep->att('systematic_name'); my $pname = $rep->first_child('gene')->att('primary_name'); $data{$name} = [$name, $sname, $pname]; } __END__ $VAR1 = { 'A_24_P344666' => [ 'A_24_P344666', 'NM_020341', 'PAK7' ], 'foo' => [ 'foo', 'boo', 'goo' ] };

In reply to Re: XML::Simple and pseudo hashes... by toolic
in thread XML::Simple and pseudo hashes... by nickschurch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.