Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Creating a hash out of multiple XML attributes in an elment

by perlvroom (Acolyte)
on Jul 14, 2013 at 21:39 UTC ( #1044238=note: print w/ replies, xml ) Need Help??


in reply to Re: Creating a hash out of multiple XML attributes in an elment
in thread Creating a hash out of multiple XML attributes in an elment

Yep. This is going to be a stupid question but how do i retrieve/print the value for, say, key "a"?


Comment on Re^2: Creating a hash out of multiple XML attributes in an elment
Replies are listed 'Best First'.
Re^3: Creating a hash out of multiple XML attributes in an elment
by mirod (Canon) on Jul 15, 2013 at 02:02 UTC

    $key2value is a hash reference, you retrieve the value for a this way: $key2value->{a}

    see perldata for more info.

      I had tried that at first and it does print the value, but it also prints: Use of uninitialized value $key2value{"a"} in concatenation (.) or string for each "settings" element in the xml.

        $key2value{"a"} and $key2value->{"a"} are two different and absolutely unrelated things. The first attempts to get the value of the key "a" in hash %key2value, the other in the hash referenced by the scalar variable $key2value. Two different variables, no surprise that you do not find anything in one after you wrote to the other.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

Re^3: Creating a hash out of multiple XML attributes in an elment
by Anonymous Monk on Jul 14, 2013 at 23:32 UTC

    mirod used a key called "key", if you want a key called "a", maybe you should replace "key" with "a" or something like that, I haven't read perlintro so I'm not sure

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-08-27 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (332 votes), past polls