[Wellington-pm] Creating an array of objects
Cliff Pratt
enkidu at cliffp.com
Sat Mar 11 00:58:12 PST 2006
I'm not very good at the OO stuff, so bear with me, please!
What I want to do is create an array of objects. Or is that an array of
object references. I'm not sure.
I can, I believe, instantiate an object as follows (please correct me if
I'm wrong)
my $foo = MyPackage->new('bar') ;
Is $foo an object or an object reference?
I basically want to create an array of objects or object refs, so can I do :
my @foo;
$foo[0] = MyPackage->new('tut') ;
$foo[1] = MyPackage->new('ankh') ;
$foo[2] = MyPackage->new('amun') ;
Obviously this could be done using a loop, but what if I needed an array
of a hundred of them? Is there a clever way to instantiate a hundred
objects of a particular class?
Am I making sense? The experienced OO programmers are probably laughing
themselves silly by now....
Cheers,
Cliff
--
http://barzoomian.blogspot.com
More information about the Wellington-pm
mailing list