(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:
require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(name1 name2 name3 ...);
Then when I include that package using 'use mypackage;', the namespace elements are available to my main routine.

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?

In reply to Exporting namespace elements when package is in same file as main by puterboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.