Am Donnerstag, 7. April 2005 14.54 schrieb Vladimir D Belousov:
> Hallo, all!

Hi 

Wim has already presented the solution for your problem;

[...]

> I do this:
> $#array = $N+100;
> print_array($array[$N]);

this should be

   print $array->[$N]

because you have to dereference the arrayref first to point to the elements of 
the array behind the arrayref.

my @array = ( qw / a b c d /); # (flat) array
my $element=$array[1]; # access element in flat array
my $arrayref = [EMAIL PROTECTED]; # make a reference (arrayref)
my $same_element=$arrayref->[1]; # and dereference while accessing element

Have a look into (from cmdline)
   perlref perltut

> But I got error: [Not an ARRAY reference at ... ]

Or, in other words, you tried to take an array element out of a scalar value 
(a reference is a scalar value).

> Is ARRAY reference in perl not the reference to the first element of ARRAY

Not in the same sense as in C.

[...]

joe

-- 
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