Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Re: Setting the value of a complicated hash ref

by poj (Abbot)
on Dec 30, 2002 at 10:17 UTC ( #223013=note: print w/replies, xml ) Need Help??

in reply to Re: Setting the value of a complicated hash ref
in thread Setting the value of a complicated hash ref

I think the reason my fix works is this;
You are building a HOH by adding to it at each start_tag here -
$pos[$depth] = \${$pos[$depth - 1]}->{$element->{Name}};
If later, you allow a text string to be assigned to $pos[$depth] then at the next depth the program fails because \${$pos[$depth - 1]} is now not a hash reference.
The text string should only be assigned when you reach the lowest level. In your XML data this conveniently is when there are no line breaks in the data. This is a big assumption and I would not do this for a serious application - much better to use the proper tools.
Hope this helps, I too am learning from this

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://223013]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-07-02 06:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found