puterboy has asked for the wisdom of the Perl Monks concerning the following question:
(disclaimer: I know that putting packages in the same file as 'main' is discouraged, but in this case I need to have it all in one file for distribution)
When a package is in a separate file, I know I can export various namespace elements by using:
Now in my case, the packages lie within the same file as my main routine (I surround each package with a 'BEGIN { }' block) so I don't need to (and can't) use 'use' to include the package and its exported namespace elements.
So, is there some way that I can 'import' the exported symbols when the package where they are exported is in the same file as main?
When a package is in a separate file, I know I can export various namespace elements by using:
Then when I include that package using 'use mypackage;', the namespace elements are available to my main routine.require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(name1 name2 name3 ...);
Now in my case, the packages lie within the same file as my main routine (I surround each package with a 'BEGIN { }' block) so I don't need to (and can't) use 'use' to include the package and its exported namespace elements.
So, is there some way that I can 'import' the exported symbols when the package where they are exported is in the same file as main?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Exporting namespace elements when package is in same file as main
by BrowserUk (Patriarch) on Feb 02, 2014 at 17:41 UTC | |
by puterboy (Scribe) on Feb 02, 2014 at 17:55 UTC | |
Re: Exporting namespace elements when package is in same file as main (BEGIN)
by tye (Sage) on Feb 02, 2014 at 19:57 UTC | |
Re: Exporting namespace elements when package is in same file as main
by tobyink (Canon) on Feb 02, 2014 at 21:48 UTC |
Back to
Seekers of Perl Wisdom