In Perl, is it possible to list all objects of a specific class?
For example, I have two objects of class Character
:
my $char1 = Character->new('John');
my $char2 = Character->new('Adam');
Now, I want to iterate over all Character
objects ($char1
and $char2
), like :
foreach ( "objects Character" ) {
print "$_->getName()\n";
}