I just wrote this little module. The problem it tries to solve is the following.
I have a set of packages, each of which specifies a part of the behaviour I need. The idea is to be able to exchange one specification with another (for those who know, I'm translating an ASM specification).
I wrote the subs in the packages to be used as methods, and one of the packages defines new, but this is not really relevant...
What I can do is something like:
package a;
sub sa { return 1 }
sub sb { return 2 }
package b;
sub sb { return 3 }
package main;
use Class::Merge qw(b a) => 'c';
$r= c->sb(); # returns 3
This, coupled with NEXT, gets me the result I need.
Now I ask:
- Is this useful to anybody else?
- Might it be worthy of CPAN?
- I currently call it Class::Merge, but since it doesn't really involve classes, what could be a better name?
Oh, the whole module boils down to:
sub import {
my $dest=pop;
shift;
eval <<"EOF";
package $dest;
\@${dest}::ISA=qw(@_);
EOF
}
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.