in reply to Perl Modules Question
I wish that I had found this little jewel m-u-c-h sooner: UNIVERSAL::require.
You are definitely on the right path by defining each Operation as a .pm file in a folder. Now, simply let that entire folder become a Perl package. Begin each file with package Operations::name;, and end each file with 1; (since every package-file must return True), and you are pretty much there. You can also create an Operations.pm package in the parent folder and put common-methods there ... a parent class, of which each of the specific operations is now a descendent. Then, before invoking a particular operation, you require it (using UNIVERSAL::require for much Perl Goodness). (It’s not a problem if it’s already there.) And now, you have now achieved your (extendable) goal with an excellent base architecture. You can add new Operations files as often as you want to, and it will Just Work.™
My superficial sense of the pluggables module that you’ve been looking at, is that it is not quite aiming to solve the same problem that you are. (But a peek into its source-code might be informative, to see just how it does what it does set out to do ...)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Modules Question
by anshumangoyal (Scribe) on Apr 30, 2012 at 14:32 UTC |