>>>>> "Nick" == Nick Transier <[EMAIL PROTECTED]> writes:
Nick> Given that I am trying to define an object attribute which is an array
Nick> of references to other object of the same type, how do I define this
Nick> in the $self portion of my sub new constructor? This is what I have,
Nick> will this work? Next is meant to hold an array of pointers or
Nick> references.
Nick> sub new {
Nick> my $invocant = shift;
Nick> my $class = ref($invocant) || $invocant;
Nick> my $self = {
Nick> Next,
Nick> @_,
Nick> };
Nick> return bless $self,$class;
Nick> }
You need an array ref there, not an array. Simplest would be a
shallow copy of the invocation list.
sub new {
my $class = shift; # do NOT use the ref() garbage, please
my $self = { Next => [@_] };
bless $self, $class;
}
You might be able to get away with \@_ in place of [@_], but I know
this is safer. :)
See "perldoc perlboot" for more details.
--
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!