dakkar has asked for the wisdom of the Perl Monks concerning the following question:
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:
Oh, the whole module boils down to:
sub import { my $dest=pop; shift; eval <<"EOF"; package $dest; \@${dest}::ISA=qw(@_); EOF }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: A module to merge packages
by tye (Sage) on Jun 26, 2002 at 14:18 UTC | |
by dakkar (Hermit) on Jun 26, 2002 at 15:36 UTC | |
|
•Re: A module to merge packages
by merlyn (Sage) on Jun 26, 2002 at 15:37 UTC | |
|
Re: A module to merge packages
by janx (Monk) on Jun 26, 2002 at 13:42 UTC | |
|
Re: A module to merge packages
by Baboon (Acolyte) on Jun 26, 2002 at 13:43 UTC | |
by dakkar (Hermit) on Jun 26, 2002 at 13:55 UTC |