in reply to Re: Can't import constants in multiple namespaces
in thread Can't import constants in multiple namespaces
use strict; use warnings; package MyMod; use Exporter (); use MyMod::db; use vars qw (@EXPORT @EXPORT_OK); use constant MYMOD_DEFAULT => 1; BEGIN { @EXPORT = (qw(MYMOD_DEFAULT)); #@EXPORT_OK = (qw(MYMOD_DEFAULT)); }; 1; use strict; use warnings; package MyMod::db; # I also tried use MyMod qw(MYMOD_DEFAULT) when constant was # in EXPORT_OK and not EXPORT. use base qw(MyMod); sub fred { print "hello" if (MYMOD_DEFAULT); } 1;
Bareword "MYMOD_DEFAULT" not allowed while "strict subs" in use at MyMod/db.pm line 6. Compilation failed in require at MyMod.pm line 5. BEGIN failed--compilation aborted at MyMod.pm line 5. My original (before simplification) was using EXPORT_TAGS.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Can't import constants in multiple namespaces
by xdg (Monsignor) on Mar 28, 2006 at 13:43 UTC | |
by mje (Curate) on Mar 28, 2006 at 14:53 UTC | |
by mje (Curate) on Mar 28, 2006 at 16:13 UTC | |
by xdg (Monsignor) on Mar 28, 2006 at 16:43 UTC | |
by mje (Curate) on Mar 28, 2006 at 16:50 UTC |