This is because you gave the same name to the array and to the scalar
variables.

$array[2] means the third element of @array.
$array->[2] refers to the element from $array reference.

Teddy


----- Original Message ----- 
From: "Dave Adams" <[EMAIL PROTECTED]>
To: "beginners perl" <beginners@perl.org>
Sent: Friday, August 19, 2005 17:31 PM
Subject: References Question


In the code below, I thought $array[2] and $array->[2] were different
but they give me the same result.

Any explaination for this?

my @array = (1,2,3);
my $array [EMAIL PROTECTED];
print ref($array);
print $array[2];
print $array->[2];

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



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