That's no problem assuming your submodule is named "My_Module::My_other_module". Just have My_Module.pm say use My_Module::My_other_module.

(I'm not trying to say they have to be nested like that, just that there is no automatic nesting done for you.)

Example:

$ cat script.pl use strict; use warnings; use Foo; print "calling Foo::mysub\n"; Foo::mysub(); print "calling Bar::mysub\n"; Bar::mysub(); $ cat Foo.pm package Foo; use strict; use warnings; use Bar; sub mysub { print "I'm a sub in ", __PACKAGE__, "\n" } 1; $ cat Bar.pm package Bar; use strict; use warnings; sub mysub { print "I'm a sub in ", __PACKAGE__, "\n" } 1; $ perl script.pl calling Foo::mysub I'm a sub in Foo calling Bar::mysub I'm a sub in Bar
All this applies if you are not exporting anything. If you want things from Bar to export to script, you can either set up Bar to export them (so they are imported to Foo) and Foo to export them also (so they are imported to script); or use Abigail's suggestion of export_to_level (see Exporter doc) to do it in one fell swoop.

In reply to Re: Loading modules through one main module? by ysth
in thread Loading modules through one main module? by stonecolddevin

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.