So, I coded a package which describes an object, and I'm having a couple of issues. Primarily, I want to know if I can make a list, each entry of which is an object (or a reference to an object). i.e.:
for ($i=0; $i<10; $i++) {
$list[$i] = Object->new();
}
Is this valid? And if so, how do I access the data this object later on? I'm relatively new to perl and using references in general.
Also, in each of these objects, I have an entry in an anonymous hash which itself is a list (of scalars). This seems to work, but it definitely seems a little shady to me. The new method looks something like:
sub new
{
my $Class = shift;
my $self = {};
$self->{Direction};
bless $self, $Class;
}
Where $self->{Direction} is an array of scalars. Once I have the list of objects, how do I then access an element in the {Direction} list of an element in the list of objects?
Any info anyone could give me on this would be greatly appreciated. TIA -
hagbardc
for ($i=0; $i<10; $i++) {
$list[$i] = Object->new();
}
Is this valid? And if so, how do I access the data this object later on? I'm relatively new to perl and using references in general.
Also, in each of these objects, I have an entry in an anonymous hash which itself is a list (of scalars). This seems to work, but it definitely seems a little shady to me. The new method looks something like:
sub new
{
my $Class = shift;
my $self = {};
$self->{Direction};
bless $self, $Class;
}
Where $self->{Direction} is an array of scalars. Once I have the list of objects, how do I then access an element in the {Direction} list of an element in the list of objects?
Any info anyone could give me on this would be greatly appreciated. TIA -
hagbardc