I was noticing in some module libraries, the caller was required to use Library::This and use Library::That separately. Other libraries had a "meta" module which would have the effect of importing all of the others for you in one simple use Library statement.

Normally, if a package uses some other module, the symbols are only imported for the package's use. With the caller function, a crafty meta-package can emulate the use statements on behalf of the main script. This can make the Library more friendly to use and document.

package Library; ... sub import { my $calling = (caller())[0]; eval qq{ # Load these on behalf of the calling package. package $calling; use Library::This; use Library::That; use Library::TheOther::Thing; }; die $@ if $@; }

In reply to Meta Module imports several packages by halley

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.