in reply to A lexical lib pragma?
Consider the following:
sub foo { say "Pragma out of scope:"; say for @INC; } { use lib::lexical 'path'; say "Pragma in scope:"; say for @INC; foo(); }
If the pragma modifies @INC and resets it at end of scope, foo will see the change. A hook is by far the easiest solution. Otherwise, you have to convince the parser to handle use, require and do differently than normal.
do and require can be done using an opcode checker, but use can't be done that way because of its compile-time effect. Maybe a call_parser/call_checker would work?
Anyway, I don't see the point of such a pragma. One a module is loaded, it stays loaded regardless of any changes to @INC, so the effect of changing @INC is global even if the change is temporary.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A lexical lib pragma?
by perlancar (Hermit) on Jan 04, 2020 at 08:01 UTC | |
by ikegami (Patriarch) on Jan 04, 2020 at 08:28 UTC |