in reply to How to declare globally visible subroutine like built-in ones ? Is it possible?
Are you sure you don't wan't use y; or require y; in z.pm?? This means that your depending on y.pm being loaded somewhere else, which is a pretty big trap for someone, yourself probably, debugging latter.
In any case, if you only want to use it from within package z, you could do this in y.pm
If you don't like "G::global_sub", how about "::global_sub"? Think of '::' as a sigil (or twigil) for global. And as long as you use package declartions everywhere, you won't stomp on anyone elses namespace.sub z::global_sub { print "global_sub working!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to declare globally visible subroutine like built-in ones ? Is it possible?
by bdimych (Monk) on Nov 06, 2007 at 12:14 UTC | |
by Anonymous Monk on Nov 06, 2007 at 13:00 UTC |