in reply to Re^2: help with "symbol lookup error" message
in thread help with "symbol lookup error" message

This question is tangential to my main issue, but since I've never seen the code before, could you please explain what exactly this is doing:

unshift @INC, sub { warn "Loading $_[1]\n"; 0; };

It looks like it's creating an array of subroutines, where each subroutine just prints the same element (1). The 0 I'm guessing is just a required return value? I must be missing something here.

Replies are listed 'Best First'.
Re^4: help with "symbol lookup error" message
by choroba (Cardinal) on Jan 27, 2023 at 23:23 UTC
    @INC hooks are described under require. To simplify, this will output all the modules your running program is trying to load.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^4: help with "symbol lookup error" message
by Anonymous Monk on Jan 28, 2023 at 06:23 UTC
    > The 0 I'm guessing is just a required return value?

    The zero is not required.

    unshift @INC, sub { warn "Loading $_[1]\n" };
    Does the same thing.
Re^4: help with "symbol lookup error" message
by Anonymous Monk on Jan 28, 2023 at 06:04 UTC
    > what exactly this is doing

    I don't know but hacked it to make this cool error message:

    perl -Mstrict -le 'BEGIN{unshift@INC,sub{$$_[1]}};use Math::Trig'
    Warning: failed to load Config_git.pl, something strange about this perl...