accessing data element in a given variable

  • Thread starter Greg Scharlemann
  • Start date
G

Greg Scharlemann

I made a call to a given web server to translate a US address its
lat/lon position and I was returned a variable $result. When I do


print Dumper $result;


The following prints:


$VAR1 = [
bless( {
'number' => '1600',
'street' => 'Pennsylvania',
'lat' => '38.898748',
'state' => 'DC',
'city' => 'Washington',
'zip' => '20502',
'suffix' => 'NW',
'long' => '-77.037684',
'type' => 'Ave',
'prefix' => ''
}, 'GeocoderResult' )
];


My question: How do I access the elements within $result?
i.e.
print $result->{state}; #doesn't print anything


Thanks for your help
 
J

John W. Krahn

Greg said:
I made a call to a given web server to translate a US address its
lat/lon position and I was returned a variable $result. When I do


print Dumper $result;


The following prints:


$VAR1 = [
bless( {
'number' => '1600',
'street' => 'Pennsylvania',
'lat' => '38.898748',
'state' => 'DC',
'city' => 'Washington',
'zip' => '20502',
'suffix' => 'NW',
'long' => '-77.037684',
'type' => 'Ave',
'prefix' => ''
}, 'GeocoderResult' )
];


My question: How do I access the elements within $result?
i.e.
print $result->{state}; #doesn't print anything

print $result->[0]{state};


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top