in reply to Re^3: A lexical lib pragma?
in thread A lexical lib pragma?

I do want it to affect 'use' too, as well as require/do.

Note that LanX's Filter::Inject is different from a traditional source filter...

Color me intrigued. Checking the module as well as the talk. Thanks!

Replies are listed 'Best First'.
Re^5: A lexical lib pragma?
by haukex (Archbishop) on Jan 04, 2020 at 21:47 UTC
    I do want it to affect 'use' too, as well as require/do.

    In that case I think you'll have to use B::Hooks::EndOfScope. For dynamic scoping at runtime, I imagine Filter::Inject could be used to inject a piece of code that basically makes a local change to @INC. For either compile or runtime, if you want it to be lexically scoped, I still can't think of a better way than an @INC hook and %^H. Although I also still can't imagine a use case for use with a lexically scoped @INC :-/