Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-25 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found