in reply to Multiple Packages in a Module?
If you want to play it safe and check that a package contained in test_v1.pm isn't loaded by a use package; statement somewhere else, insert the following code at the top of the test_vN.pm files. This won't protect you against loading more than one test_vN.pm file, but if that does happen, and you have warnings enabled (which you always should, of course), you should see some "Subroutine redefined" warnings (Update: I hope that test_v1.pm and test_v2.pm defining at least a few of the same subs is a safe assumption).
use Module::Runtime qw/module_notional_filename/; BEGIN { for my $package (qw/ Foo Foo::Bar /) { my $fn = module_notional_filename($package); die "$package already loaded from $INC{$fn}" if exists $INC{$fn}; $INC{$fn} = __FILE__; } }
|
|---|