in reply to Can't import constants in multiple namespaces
defined and exported in one module to a lower level module
You should be aware that the notion of "lower level" doesn't matter for this kind of thing. While there is a hierarchy of namespaces, Perl doesn't automatically do anything with it. Nothing is exported to lower levels by default. Likewise, lower levels do not inherit methods from upper levels. The hierarchy is entirely a convenience for users.
As Joost said, you have to "use" the module at the lower level for it to work. Likewise, for object oriented programming, you have to "use base" or otherwise set the @ISA array.
package My::Class; sub foo { print "Foo" } 1;
package My::Class::Reversed; use base qw( My::Class ); sub foo { print reverse "Foo" } 1;
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't import constants in multiple namespaces
by mje (Curate) on Mar 28, 2006 at 12:57 UTC | |
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 |