You don't use a filename with use(), and it's not just flat namespaces that have the problem.

The problem is a combination of the inner workings of %INC and @INC. If @INC has a relative path in it, and it finds the requested module in the current working directory, it loads it. That could be a name like ./Module.pm or nested path like ./Foo/Bar/Baz/Module.pm. Later in the script (or system like mod_perl), if we try the same thing from a different directory where there is the same relative path but to a different module, %INC thinks it already loaded it. It's the path that matters, not the module file name. %INC just stores the path name. A relative path can represent multiple files, but an absolute path points to one file.

This doesn't bite people with regular scripts because they don't have to worry about persistence. This bites people under mod_perl because a lot of scripts share %INC, and somebody may have already loaded a module. It only bites them if they use relative paths in @INC. If they don't do that, they should get what they expect. Modules like FindBin can help a script figure out where it is, although I prefer to simply install modules in known locations.

Still, this doesn't have anything to do with the layout of a distribution or what its files should be named, at least no more than it does in any other situation.

--
brian d foy <bdfoy@cpan.org>

In reply to Re^2: Separate files for CPAN dist by brian_d_foy
in thread Separate files for CPAN dist by jacques

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.