Dan,

It appears the $apple->[2] and $apple[2] are not the same thing.


#!/usr/bin/perl -w
use strict;

my $apple = [4,5,6]; #example of a scalar representing an array

print ref($apple) . $apple->[2] . "\n";
print ref($apple) . $apple[2] . "\n";


errror msg:

Global symbol "@apple" requires explicit package name at
F:\perlex\Perl-1.pl line 7.
Execution of F:\perlex\Perl-1.pl aborted due to compilation errors.

On 8/19/05, Dan Klose <[EMAIL PROTECTED]> wrote:
> Hello again,
> 
> for an intriduction to refs check chapter 1 of advance perl programming
> by Srinivasan & O'Reilly Press.  Its very quick and very clear.
> 
> On Fri, 2005-08-19 at 10:31 -0400, Dave Adams wrote:
> > In the code below, I thought $array[2] and $array->[2] were different
> > but they give me the same result.
> >
> > Any explaination for this?
> >
> Try this: untested - and i don't usually use refs.
> > my @array = (1,2,3);
> my $array_ref = [EMAIL PROTECTED]
> > my $array [EMAIL PROTECTED];
> #Not sure what this does below.
> > print ref($array);
> print @$array_ref[2];
> > print $array[2];
> > print $array->[2];
> >
> --
> Daniel Klose
> PhD Student - Taylor Group
> Mathematical Biology
> National Institute for Medical Research
> The Ridgeway
> Mill Hill
> London
> NW7 1AA
> 
>

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