Thanks for the help. I wasn't initializing the $self->{ARRAY} with [].
But later in the code I need to do something like this:
@self->{ARRAY} = @another_array; # of course this is giving me an error.
Do I have to do:
for ($i=0;$i<$#another_array;$i++) {
$self->{ARRAY}[$i] = $another_array[$i]
}
or there's something smarter?
----------------------------------------------------------------------------
"Brett W. McCoy" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sat, 8 Sep 2001, Gustavo A. Baratto wrote:
>
> > How can I have an array in a class attribute?
> >
> > In my constuctor this is not working: (I need $self->{ARRAY} to be an
array)
> >
> >
> > sub new
> > {
> > my $class = shift;
> > my $self = { };
> > $self->{IFCONFIG} = "/etc/ifconfig.temp";
> > $self->{NEWIP} = "/home2/nas3/nas/.newip.temp";
> > $self->{IP} = undef;
> > $self->{SOURCE} = "ifconfig";
> > $self->{ARRAY} = undef;
> >
> > bless($self, $class);
> > return($self);
> > }
>
> How are you initializing this? It has to be an array reference:
>
> $self->{ARRAY} = [ 0, 1, 2, 3, 5 ];
>
> -- Brett
> http://www.chapelperilous.net/
> ------------------------------------------------------------------------
> A poet who reads his verse in public may have other nasty habits.
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]