in reply to XML::Simple and pseudo hashes...

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' ] };

Replies are listed 'Best First'.
Re^2: XML::Simple and pseudo hashes...
by nickschurch (Acolyte) on Jun 22, 2009 at 13:38 UTC
    With a bit of playing, XML::Twig has done the trick and given me what I want. Iget some weird behaviour after it though... The script keeps running and everything looks good, but then I get a segmentation fault as the script ends.

    I know its as it end cos everything is fine, including the print "... fininshed!\n"; final line, before it segmentation faults. Weird. Still, I don't s'pose it matter at that point.