in reply to Re: dynamically expand @INC beyond BEGIN
in thread dynamically expand @INC beyond BEGIN

feeling stupid at the moment.

All morning it was continually saying cannot find MODULE.pm in <@INC_DIRS>, with the front dir being the one loaded that has the module in it. I couldn't figure why it would work when defined in the BEGIN block, but not in my code body and thought it had to be something to do with perl/@INC. Tried it one more time in the body and now it's working just fine. No idea what I had wrong there previously.

Thanks for your help.

  • Comment on Re^2: dynamically expand @INC beyond BEGIN

Replies are listed 'Best First'.
Re^3: dynamically expand @INC beyond BEGIN
by ikegami (Patriarch) on Apr 17, 2012 at 04:22 UTC

    Note that require "$lib/Module.pm" would also have worked if $lib contains an absolute directory (and probably even if it doesn't?)

    You could also make the change to @INC temporary using local @INC = ( $lib, @INC );.

      thanks, if $lib/$module.pm had all the code I needed then require would work. Instead, it contains about 30 use statements for other modules where the all code is stored, hence the reason why @INC needs $module loaded.