O
Overt
Don't anybody laugh. I am trying to learn Object Perl and modifying
examples in the books just to understand what is going on.
Here is a simple object creation where I am using an array rather than a
hash.
Called with this -
my @tarray;
$tarray[0][0] = 1;
$tarray[0][1] = 2;
$tarray[1][0] = 3;
$tarray[1][1] = 4;
my $displayobj = Display->new(\@tarray);
Here is the constructor -
sub new {
my $class = shift;
my $self = [];
$self->[@_] = shift;
bless($self, $class);
$DB::single = 1; #this is where I examine $self
return $self;
}
It works ok, but $self contains an array of an array, rather than just a 2
dimentional array. Like so
$self[0][0][0] = [1]
$self[0][0][1] = [2]
$self[0][1][0] = [3]
$self[0][1][1] = [4]
Why an array of an array, rather than just an array?
Again, this isn't a problem I am trying to fix, just something I am trying
to understand.
Thanx anybody
Overt
examples in the books just to understand what is going on.
Here is a simple object creation where I am using an array rather than a
hash.
Called with this -
my @tarray;
$tarray[0][0] = 1;
$tarray[0][1] = 2;
$tarray[1][0] = 3;
$tarray[1][1] = 4;
my $displayobj = Display->new(\@tarray);
Here is the constructor -
sub new {
my $class = shift;
my $self = [];
$self->[@_] = shift;
bless($self, $class);
$DB::single = 1; #this is where I examine $self
return $self;
}
It works ok, but $self contains an array of an array, rather than just a 2
dimentional array. Like so
$self[0][0][0] = [1]
$self[0][0][1] = [2]
$self[0][1][0] = [3]
$self[0][1][1] = [4]
Why an array of an array, rather than just an array?
Again, this isn't a problem I am trying to fix, just something I am trying
to understand.
Thanx anybody
Overt