|
|
| The stupid question is the question not asked | |
| PerlMonks |
Re: Loading PERL Module from scalar in RAM? (@INC hook)by LanX (Saint) |
| on Apr 16, 2023 at 19:32 UTC ( [id://11151705]=note: print w/replies, xml ) | Need Help?? |
|
@INC has a hook mechanism, where you can place a callback instead of a string path. The callback can decide to return the code if encountered by require while working thru @INC. The interface is a bit convoluted but it works. After adding the hook inside BEGIN you can call use or require deeply hidden inside foreign code and your "RAM modules" are installed.
quotes from the docs
You can also insert hooks into the file inclusion system by putting Perl code directly into @INC. Those hooks may be subroutine references, array references or blessed objects. See "require" in perlfunc for details.
edithere some example code from an older discussion in that case the code is fetched via HTTP, but it should be easy to to just fill in your RAM stuff instead.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||