accessing data element in a given variable

Discussion in 'Perl Misc' started by Greg Scharlemann, Aug 2, 2005.

  1. 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
    Greg Scharlemann, Aug 2, 2005
    #1
    1. Advertising

  2. Greg Scharlemann wrote:
    > 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
    --
    use Perl;
    program
    fulfillment
    John W. Krahn, Aug 2, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    551
    Thomas Weidenfeller
    Apr 19, 2006
  2. Replies:
    4
    Views:
    2,513
  3. Cal Who
    Replies:
    13
    Views:
    1,664
    Registered User
    May 23, 2010
  4. Kourosh
    Replies:
    1
    Views:
    114
    Kourosh
    Jun 8, 2006
  5. \A_Michigan_User\
    Replies:
    4
    Views:
    143
    Thomas 'PointedEars' Lahn
    Nov 16, 2007
Loading...

Share This Page