Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: multiple XML fields in one line

by poj (Monsignor)
on Aug 07, 2014 at 17:27 UTC ( #1096671=note: print w/replies, xml ) Need Help??

in reply to multiple XML fields in one line

Try replacing this one line in sub getMicroOrgs

push @{$ret}, $_->{Hit_def} foreach (@{$hits});


foreach (@{$hits}) { push @{$ret},join '|', $_->{Hit_def}, $_->{Hit_num}, $_->{Hit_hsps}->{Hsp}->{Hsp_identity}; }


Replies are listed 'Best First'.
Re^2: multiple XML fields in one line
by smice (Initiate) on Aug 08, 2014 at 16:17 UTC

    Thanks a lot for your help! Much appreciated.

    However, now the script is not working, it exits with an error message: "Not a HASH reference at line 102." It points to this line:

    push @{$ret},join '|',

    Something seems to be wrong with @{$ret}; I am educating myself on how Perl handles arrays, hashes, references and such, but in the meanwhile I'd be grateful if you would share your thoughts on this. Why it is not working now when previously it worked with the single XML field?

    Thanks a lot again!

      Can you provide a small sample of the XML file that fails.

        Yep, here is the first part, after the <Iteration_hits> there are lots of <Hit>-s, all with exactly the same structure, so I kept only the first two. The point is to search in the <Hit_def> of these <Hit>-s, but in the output we'd like to see the <Hit_num> and <Hsp_identity> attributes of the matching <Hit>-s too.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1096671]
[jedikaiti]: Hi Monks

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-01-22 17:28 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (235 votes). Check out past polls.