in reply to Re^3: Multiple Packages in a Module? (%INC)
in thread Multiple Packages in a Module?

I have problems to see a case where my approach doesn't work.

I can't see a case where it wouldn't "work", but I also can't see any typical case in which it would do anything useful.

Assuming an unambiguous file system, if you have a xyzzy.pm file defining a package Foo and its structure/content and a bunch of other namespaces and their contents, the only way to establish the Foo namespace (and all the others) is by a  use xyzzy; statement. Once the  use xyzzy; statement is executed, all the namespaces are established, and xyzzy cannot be use-ed again with any effect because it is present in the  %INC structure. If one then wants to access one of these namespaces, a  packagenamespace; statement will do the trick.

OTOH, if you have a Perl inclusion directory structure with a slew of Foo.pm files in it, any  use Foo; statement is an open invitation to a major brain tumor. Surely, the best approach is to have a clean, unambiguous inclusion path to begin with. If you have some weird monkey patching/phasing/path resolution/??? problem such as haukex alludes to here, patching  %INC in this way may be your only salvation, but again, isn't studious avoidance rather than acceptance the best way to deal with such an unusual (one would hope) situation?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^5: Multiple Packages in a Module? (%INC)
by LanX (Saint) on Jun 25, 2018 at 22:29 UTC
    > but I also can't see any typical case in which it would do anything useful.

    PAR::Packer and relatives?

    update

    or let's assume a situation where you have to transport/pipe multi-module Perl code to a running script.

    The OP was talking about testing, we can't know what exactly he's trying to test.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery