My idea is something more complex along the line first one wins, second one gets renamed.

I think that any module that is already registered under a key should be available with that key while the program is running. And any module wanting to be registered should be registered. This implies that there may be cases when two modules want to be registered with the same key (think of two plugins by different authors). In that case I would register it with another key. To use the second module, the program has to know the new key. Thats why plug_in() should return the real key under which it registered the module.

The interface could be like this for plugin modules:

package MyPluginLibA; use Algorithm::CheckDigits; our @EXPORT = qw( CheckDigits ); our @ISA = qw(Algorithm::CheckDigits); our $method = Algorithm::CheckDigits::plug_in('mpla','MyPluginLibA');

Inheritance and reexport of CheckDigits() is just for convenient use of the plugin module. So the user of the plugin module does not need to use Algorithm::CheckDigits; but can use the interface.

And then it looks like this for the user of the plugin module:

use MyPluginLibA; my $cd = CheckDigits($MyPluginLibA::method);

Algorithm::CheckDigits::plug_in() would only get two arguments, the key and the module name. If the key is already in use, it would find another key to add the module name and return that other key.

If there is a module that behaves differently for variations of the key (like the module that computes check digits for VISA, AMEX, ISIN, IMEI, ...) it would have to provide a mapping between the intended key and the one returned by Algorithm::CheckDigits::plug_in(). And it should clearly document how to access the different keys.

Would that be too complex?

Update: tried to make my intention more clear


In reply to Re^2: Plugin Overwriting or saving keys in Algorithm::CheckDigits configuration by mamawe
in thread Plugin Overwriting or saving keys in Algorithm::CheckDigits configuration by MidLifeXis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.