Hello Monks,
I have a base class which many other classes inherit from. During the init process of those child classes they want to dynamicly create methods based on init
paramaters. This will only happen once and will happen for each of the child classes.
I would like to do something like this:
*{"${class}::$method"} = sub {
my $self = shift;
#more dynamic build stuff here
return $self;
};
The thing I dont like is I have to wrap it all in a block and do a
no strict 'refs'.
Keeping in mind the methods really do need to be generated during the init phase, dynaicaly, is there anything wrong with the approach? I assume there must be some nasties if I have to turn off strict refs... What do I need to know?
Thanks!!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.