Hi, I'm very beginner of Perl, I have some problem about module loading(?)

I'm running simulation with some script file. This script contains line "package That::Module" to use the subroutine of a package in a module.(blessed subroutine) However, that module is located in the root directory "other/root/directory/Module.pm" different from my simulation directory "My/Directory/Simulation/script".

I think this is possible because @INC already has a path to find the module. (I checked with perl -V, but fail to find exact module path. but script runs successfully anyway) script can run succesfully without line "package That::Module" too. I think it's because the path is environmentally defined and there is no subroutine with the same name in @INC.

For the test, I created another directory and put same script file like this.

My/test/Directory/script2 (same code except "That::Module" -> "This::Module". Intentionally changed to prevent conflicts with existing module "That::Module".) And module file My/test/Directory/This/Module.pm

But for the successful execution, I had to add line "use This::Module" in script2 before(or after) line "package This::Module". I tried both <perl option: perl -I My/test/Directory/This script2> and <use lib '/My/.../This';>line in script2. but still need "use This::Module" line.

I want to know how my simulation script runs successfully without the phrase "use". (Is it defined in a location I don't know?) And want to know how to add(or load? or install? I have some confusion about this.) module and run script2 without the phrase "use" in my test directory.


In reply to Difference in Module loading and install?? by Lewis

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.