in reply to without CPAN, templates and random named module class members

I'm sorry but I don't understand what you are asking, in both questions.

I think in your first question, you want to compose a class from two other base classes, but I don't understand what part should be abstract ("Race", "Class") and what part should be concrete ("Elf", "Ranger"), or where your problem is.

My approach for the first topic would be to keep the race and class of a character as separate objects in the player character. Maybe some transmutation changes the race of a character. Also, the boni/mali usually conferred by race and class are quite similar, so I think it would be more beneficial to keep them the same and have them add/subtract from the player base stats.

sub HollyGame::ElfRanger::new { my( $class, %options ) = @_; $options{ class } = HollyGame::Ranger->new(...); $options{ race } = HollyGame::Elf->new(...); bless \%options => $class; }

If you want to make even that more generic, you can maybe glean the race+class from the classname:

sub HollyGame::RaceClassBase::new { my( $class, %options ) = @_; my( $race, $class ) = ($class =~ /::([A-Z][a-z]+)([A-Z][a-z]+)/); $options{ class } = "HollyGame::$class"->new(...); $options{ race } = "HollyGame::$race"->new(...); bless \%options => $class; } package HollyGame::ElfRanger; use base 'HollyGame::RaceClassBase'; ... HollyGame::ElfRanger->new();

For your second question, an "object" is just a hash, so you can of course change the key in it:

sub new { my( $class, %options) = @_; # rename from "tobechangedname" to "newname" my $optval = delete $options{ tobechangedname }; $options{ newname } = $optval; bless \%options => $class; }