You might get away with explicitly importing in your sub classes, but it might still not work, because of the order in which import() will be called, if it gets called at all, see below:
package Module::Monkey; use base 'Module'; BEGIN { Module->import(); }

Note that use base does NOT call import() on the superclass.

You're trying to use Module as a base class, and as a holder of constants to be exported, and as a "module loader" that loads all its subclasses. Life would be a lot simpler if you would drop at least one of these functions in another module, and I would recommend splitting them all out, which will make your code a lot saner:

# in Module/Loader.pm package Module::Loader; use Module; use Module::Monkey; use Module::Ape; use Module::Constants; # in Module.pm package Module; use Module::Constants; sub some_inhereted_sub { }; # in Module/Constants.pm; package Module::Constants; use constant { MDB_INT => 0, MDB_FLOAT => 1, MDB_STRING => 2, }; # in Module/Ape; package Module::Ape; use Module::Constants; use base Module;

Etc.

Hope this helps,
Joost.


In reply to Re: Problems importing constants in multiple namespaces by Joost
in thread Problems importing constants in multiple namespaces by Weevil

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.