Weevil has asked for the wisdom of the Perl Monks concerning the following question:
If I use Module; in main, the constants are imported just fine. However, if I use Module; in Module/Ape.pm or Module/Monkey.pm, the constants are not imported. I suspect it's because I did use Module::Monkey; and use Module::Ape; in Module.pm, and this is processed before the code to export the constants ever gets done. I tried putting the exporting code inside a BEGIN block, but that did not fix the problem, and surely if I put use Module; in Module/Monkey.pm, the constants should be re-imported regardless of whether Module.pm has already been loaded.# Module.pm package Module; require Exporter; # Make sure these modules are available to any script that does "use M +odule;": use Module::Monkey; use Module::Ape; use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS @ISA); @ISA = qw(Exporter); @EXPORT = qw( MDB_INT MDB_FLOAT MDB_STRING ); use constant { MDB_INT => 0, MDB_FLOAT => 1, MDB_STRING => 2, }; # bla bla bla... 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems importing constants in multiple namespaces
by ysth (Canon) on Aug 19, 2004 at 21:36 UTC | |
by Weevil (Novice) on Aug 19, 2004 at 23:51 UTC | |
|
Re: Problems importing constants in multiple namespaces
by Joost (Canon) on Aug 19, 2004 at 20:43 UTC | |
|
Re: Problems importing constants in multiple namespaces
by naChoZ (Curate) on Aug 19, 2004 at 18:22 UTC | |
|
Re: Problems importing constants in multiple namespaces
by dragonchild (Archbishop) on Aug 19, 2004 at 18:23 UTC |