So then would I access the nth element by
@{$self->{Next}}[n]  ??


>From: [EMAIL PROTECTED] (Randal L. Schwartz)
>To: "Nick Transier" <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: $self def
>Date: 20 Jun 2001 09:29:41 -0700
>
> >>>>> "Nick" == Nick Transier <[EMAIL PROTECTED]> writes:
>
>Nick> Given this is my definition for self in some new constructor:
>Nick> sub new {
>
>Nick>        $self {
>Nick>              Next => @[Max_Level],
>Nick>        }
>Nick> }
>
>Nick> First, is this the proper way to have Next be a reference to an
>Nick> annonymous array of size Max_Level?
>
>No need to predeclare a size.  Stop thinking Java/Fortran/C/C++.
>
>Arrays have a size because people put things into them!  Just let
>it start out empty, and push @{$self->{Next}}, $new each time
>you want to add one onto the end.
>
>Nick> More importantly, how do you reference the elements in the array
>Nick> referenced by Next?
>
>Just think of @{$self->{Next}} as an array:
>
>         foreach my $item (@{$self->{Next}}) {
>                 $item is one of the items
>         }
>
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
><[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl 
>training!

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to