Am Sonntag, 13. März 2005 23.47 schrieb Grant:
> I've got an array returned from Google's API and I need to get the
> data out of it.  The best I can do right now is:
>
> ARRAY(0x8262e088)

What you got is an reference to an array (an arrayref); printed out it looks 
linke something above. 

To access the array referenced to it must be dereferenced.

Documentation: perldoc perlref

Code example:

use strict;
use warnings;

my $arrayref=[qw(1 2 3 4)]; # an arrayref

print "arrayref printed: ", $arrayref, "\n"; # what you accessed
print "array referenced printed: ", @$arrayref, "\n"; # what you wanted to

my $second_value=$arrayref->[1]; # extract a value
print "second value: ", $second_value "\n";

# this prints

arrayref printed: ARRAY(0x814ac88)
array referenced printed: 1234
second value: 2

>
> Can anyone help me out?
>
> - Grant

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to