in reply to require() @INC hooks problem

Second guess, careful with private subs

my sub for_inc { my ($coderef, $filename) = @_; return \$source }; my $for_inc_ref = \&for_inc;

instead please try

my $for_inc_ref = sub { my ($coderef, $filename) = @_; return \$source };

unfortunately I can't test right now.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: require() @INC hooks problem
by kcott (Archbishop) on Dec 27, 2020 at 21:12 UTC

    Thanks for guessing; if nothing else, it eliminates possibilities.

    In earlier versions of the code, I did have what you suggest, as well as push @INC, sub { ... };. I tried both of those with and without the my ($coderef, $filename) = @_;.

    — Ken