Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^5: How come undef eq '' ??

by tmharish (Friar)
on Jan 31, 2013 at 07:05 UTC ( #1016236=note: print w/replies, xml ) Need Help??

in reply to Re^4: How come undef eq '' ??
in thread How come undef eq '' ??

This code feels... itchy... to me. No offense ;)

None Taken!

The idea of this bit is to extract the next level of an XML tree ( stored in a hash, in this case $hash )

So if ref( $hash ) ne 'HASH' then we are at a leaf and $hash is the actual value and not a sub-tree, and hence the $data = $hash ( now they are both scalar )

On the other hand, if ref($hash) eq 'HASH' then we are dealing with a sub-tree - so $data = $$hash{$name} is fine.

There is, however, one exception, and that is when '$hash' contains the key 'CONTENT' like so: $$hash{ CONTENT }. In that case $$hash{ CONTENT } is not a sub-tree but a place holder for the actual data and hence the  $data = $$data{CONTENT}

Of course this requires that CONTENT is never a key in our hash (although it might be a node in the XML) - but that is achieved during parsing of the XML into the hash.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016236]
[marto]: good morning all
[Corion]: On another topic, in the process of Rubber Duck SoPWing, I wrote a post about the best API for generating HTTP requests (not sending them) and while writing it and fleshing out my sample implementation, I came up with some improvements to my ...
[Corion]: ... existing prototype. Cartesian Products will be proud of that module once it gets out ;)
[Corion]: Hi marto ;)
LanX has the same problem with English accents ...
[LanX]: Will Cartesian Products still be tarif free after Brexit?
LanX ... though he can't lift more than one grown up at a time

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-01-18 10:21 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.