Hello fellow monks, I am a perl game programmer and would like to ask 2 questions : Can I templatize (C++) for a non player character which has a race.pm and class.pm without using e.g.
our @ISA = ("Race", "Class");
Using this I would like to use both classes to make :
package HollyGame::Entity; out @ISA = ("Race", "Class"); sub new { my ($class) = @_; $self = { ### positions and stuff }; bless $self, ref($class) || $class; };
Then do
package HollyGame::ElfRanger; out @ISA = ("Elf", "Ranger"); sub new { my ($class) = @_; $self = { ### more or less stuff }; };
Is there TMTOWTDI ? The second question is, can I use a parameter name in a $self hash of a module with a way to its change name ?
package Mod::Module; sub new { my $class = shift; $self = { tobechangedname => "value", } ### to change the tobechan +gedname at compile and runtime bless $self, ref($class) || $class; }
Thanks for any help.

In reply to without CPAN, templates and random named module class members by holyghost

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.