Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Autocreating Classes

by stvn (Monsignor)
on Oct 07, 2006 at 13:26 UTC ( #576839=note: print w/replies, xml ) Need Help??

in reply to Autocreating Classes

If you need to generate these classes dynamically at runtime, then you could use the technique Joost suggested. However, if you have a fixed set of classes which you know at compile time, and are basically just looking to save your wrists from having to type things over and over, then you could use Module::Compile::TT to just expand the code you need at module load time (actually pre compile-time phase).

package A; # ... code here use tt ( subclasses => [ map { 'B' . $_ } 1 .. 100 ] ); [% FOREACH subclass IN subclasses %] package [% subclass %]; our @ISA = qw(A); [% END %] no tt;
There is always more than one way to do it ;)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://576839]
erix ( easily amused )

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-05-22 16:08 GMT
Find Nodes?
    Voting Booth?