in reply to prove can't find my module, even though its directory is in $INC[0] (Solved)

I've found the problem. Thank you to all commenters: what you said helped me to home in on it. For those who may have a similar problem, it was the result of using "require" to load the MAS::Global module after it had already been loaded with "use". No, don't ask me why I coded it that way: it's probably because this is code re-used from another project. More specifically I had this (in summary):
use MAS::Global; ... if ( $something_irrelevant ){ require 'MAS::Global'; }
I'll mark this "solved" if I can find out how to do it.
  • Comment on Re: prove can't find my module, even though its directory is in $INC[0]
  • Download Code

Replies are listed 'Best First'.
Re^2: prove can't find my module, even though its directory is in $INC[0]
by choroba (Cardinal) on Dec 17, 2025 at 11:36 UTC
    Just edit the title of the original post, append (Solved) to it.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^2: prove can't find my module, even though its directory is in $INC[0]
by hippo (Archbishop) on Dec 17, 2025 at 13:35 UTC
    require 'MAS::Global';

    Just to hammer the point home, it is the format of this line which is the problem, not the line itself. By enclosing the module name in quotes it is no longer a bareword and therefore perl looks for a file with that exact name which of course it does not find because it does not exist. If you had omitted the quotes (as you did in the use statement) it would all have been fine. Here's a trivial illustration using a core module as an example:

    $ perl -e 'use Fcntl; require "Fcntl";' Can't locate Fcntl in @INC (@INC contains: /usr/local/lib64/perl5 /usr +/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vend +or_perl /usr/lib64/perl5 /usr/share/perl5) at -e line 1. $ perl -e 'use Fcntl; require Fcntl;' $

    See how (and why) the first one with the quotes fails but the second one without the quotes succeeds? It's the same even without the use statement but I have left it in there to mirror your use case.


    🦛

Re^2: prove can't find my module, even though its directory is in $INC[0]
by ikegami (Patriarch) on Dec 17, 2025 at 15:54 UTC

    Your analysis is incorrect. It has nothing to do with the module having already been loaded.

    That tries to load a file named MAS::Global (not MAS/Global.pm), and no such file has been loaded. Furthermore, it wouldn't be an error if it had been.

    The error is because you used require 'MAS::Global'; instead of require MAS::Global;, just like we said. (require 'MAS/Global.pm'; would also work.)