Module::Load::In::INIT - Load modules in INIT phase
This document describes version 0.005 of Module::Load::In::INIT (from Perl distribution Module-Load-In-INIT), released on 2018-02-18.
In the command-line:
% perl -MModule::Load::In::INIT=Mod::One,Mod::Two='Some;Import;Args' somescript.pl
Mod::Two will be loaded in the INIT phase instead of BEGIN phase.
Specify options for Module::Load::In::INIT itself:
% perl -MModule::Load::In::INIT=-ignore_load_error,Mod::One,Mod::Two
This module can load (or perhaps defer loading) modules in the INIT phase instead of the BEGIN phase. One use-case where it is useful: monkey-patching a module (using a Module::Patch-based module) in a fatpacked script (see Module::FatPack or App::FatPacker), e.g.:
% perl -MSome::Module::Patch::Foo fatpacked-script.pl
Some::Module::Patch::Foo will try to load
Some::Module then patch it. This might fail when module is loaded by the fatpack handler (which is a require hook) as by the time
Some::Module::Patch::Foo is loaded, the fatpack handler has not been setup yet, and
Some::Module is not available elsewhere (on the filesystem). This, however, works:
% perl -MModule::Load::In::INIT=Some::Module::Patch::Foo fatpacked-script.pl
Some::Module::Patch::Foo (and by extension,
Some::Module) is deferred to the INIT phase. By that time, the fatpack require hook has been setup and
Some::Module can be (or might already be) loaded by it.
Caveat: Module::Load::In::INIT itself must be loaded in the BEGIN phase, or INIT phase at the latest.
You can specify options for Module::Load::In::INIT itself via import argument that starts with dash ("-"). Known options:
Please visit the project's homepage at https://metacpan.org/release/Module-Load-In-INIT.
Source repository is at https://github.com/perlancar/perl-Module-Load-In-INIT.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Module-Load-In-INIT
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
This software is copyright (c) 2018, 2017 by firstname.lastname@example.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.