Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Confused about accessing hashes

by ambs (Pilgrim)
on Apr 19, 2005 at 14:14 UTC ( [id://449254]=note: print w/replies, xml ) Need Help??


in reply to Confused about accessing hashes

First, your $VAR1 is a reference to a hash with only one key, so
$VAR1->{ETPT}
is needed. This one is another reference to another hash with only the key 'SERVER', so
$VAR1->{ETPT}{SERVER}
Now, this is a reference to an array. You want to get all responses...
$VAR1->{ETPT}{SERVER}[0]{RESPONSE} # First element of the array $VAR1->{ETPT}{SERVER}[1]{RESPONSE} # Second element of the array
Probably you want to go for each element of the array like this:
for (@{$VAR1->{ETPT}{SERVER}}) { # here $_->{RESPONSE} is each response of the array }
Hope this helps.

Alberto Simões

Replies are listed 'Best First'.
Re^2: Confused about accessing hashes
by ear (Acolyte) on Apr 19, 2005 at 14:23 UTC
    Eureka! That was perfect and I actually get it now. Thanks MUCH.
    $data = $xml->XMLin ("good.xml"); . . . for (@{$data->{ETPT}{SERVER}}) { print "$_->{IP}\n\t$_->{RESPONSE}\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-16 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found