Perl Monk, Perl Meditation | |
PerlMonks |
Re: Multiple Packages in a Module? (manipulate %INC)by LanX (Saint) |
on Jun 25, 2018 at 18:45 UTC ( [id://1217380]=note: print w/replies, xml ) | Need Help?? |
> I want to have a set of files test_v1.pm .. test_vN.pm that each have definitions of package Foo and package Foo::Bar After useing test_v*.pm you have to make Perl believe that package Foo and package Foo::Bar have already been loaded ... i.e. you have to flag it in %INC: °
The hash %INC contains entries for each filename included via the do, require, or use operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. The require operator uses this hash to determine whether a particular file has already been included. I had a similar discussion some time ago, I'll dig it up and update it here.
EDITCouldn't find it, here a little demo:
HTH! :)
updateadded dump of \%INC for illustration
update˛) using __FILE__ instead of 1 is even better, because the origin of the code will become obvious when debugging.
Cheers Rolf
°) %INC the hash not @INC the array!
In Section
Seekers of Perl Wisdom
|
|