Module-Runtime-0.018/000755 000000 000000 00000000000 15001433104 014335 5ustar00rootroot000000 000000 Module-Runtime-0.018/.perlcriticrc000644 000000 000000 00000006727 15001433104 017037 0ustar00rootroot000000 000000 severity = 1 verbose = 9 only = 1 [BuiltinFunctions::ProhibitComplexMappings] max_statements = 2 [BuiltinFunctions::ProhibitLvalueSubstr] [BuiltinFunctions::ProhibitShiftRef] [BuiltinFunctions::ProhibitSleepViaSelect] [BuiltinFunctions::ProhibitStringyEval] [BuiltinFunctions::ProhibitUniversalCan] [BuiltinFunctions::ProhibitUniversalIsa] [BuiltinFunctions::ProhibitVoidGrep] [BuiltinFunctions::ProhibitVoidMap] [BuiltinFunctions::RequireGlobFunction] [BuiltinFunctions::RequireSimpleSortBlock] [ClassHierarchies::ProhibitAutoloading] [ClassHierarchies::ProhibitExplicitISA] [ClassHierarchies::ProhibitOneArgBless] [CodeLayout::ProhibitHardTabs] [CodeLayout::RequireConsistentNewlines] [ControlStructures::ProhibitDeepNests] [ControlStructures::ProhibitLabelsWithSpecialBlockNames] [ControlStructures::ProhibitMutatingListFunctions] [ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions] [ControlStructures::ProhibitUnreachableCode] [ControlStructures::ProhibitYadaOperator] ; [ErrorHandling::RequireCarping] ; no loading modules [ErrorHandling::RequireCheckingReturnValueOfEval] [InputOutput::ProhibitBacktickOperators] [InputOutput::ProhibitBarewordFileHandles] [InputOutput::ProhibitExplicitStdin] [InputOutput::ProhibitJoinedReadline] [InputOutput::ProhibitOneArgSelect] [InputOutput::ProhibitReadlineInForLoop] [InputOutput::ProhibitTwoArgOpen] [InputOutput::RequireBriefOpen] [InputOutput::RequireCheckedOpen] [InputOutput::RequireEncodingWithUTF8Layer] [Miscellanea::ProhibitFormats] [Miscellanea::ProhibitUnrestrictedNoCritic] [Modules::ProhibitAutomaticExportation] [Modules::ProhibitConditionalUseStatements] [Modules::ProhibitEvilModules] [Modules::ProhibitExcessMainComplexity] [Modules::RequireBarewordIncludes] [Modules::RequireEndWithOne] [Modules::RequireExplicitPackage] allow_import_of = warnings experimental [Modules::RequireFilenameMatchesPackage] [NamingConventions::ProhibitAmbiguousNames] [Objects::ProhibitIndirectSyntax] [RegularExpressions::ProhibitCaptureWithoutTest] [RegularExpressions::ProhibitComplexRegexes] [RegularExpressions::ProhibitUnusedCapture] [Subroutines::ProhibitBuiltinHomonyms] [Subroutines::ProhibitExcessComplexity] max_mccabe = 30 [Subroutines::ProhibitManyArgs] [Subroutines::ProhibitNestedSubs] [Subroutines::ProhibitReturnSort] [Subroutines::ProhibitUnusedPrivateSubroutines] allow_name_regex = _build_\w+ [Subroutines::ProtectPrivateSubs] [TestingAndDebugging::ProhibitProlongedStrictureOverride] [TestingAndDebugging::RequireTestLabels] ; [TestingAndDebugging::RequireUseStrict] ; no loading modules ; [TestingAndDebugging::RequireUseWarnings] ; no loading modules [ValuesAndExpressions::ProhibitCommaSeparatedStatements] [ValuesAndExpressions::ProhibitComplexVersion] [ValuesAndExpressions::ProhibitImplicitNewlines] [ValuesAndExpressions::ProhibitLeadingZeros] [ValuesAndExpressions::ProhibitMismatchedOperators] [ValuesAndExpressions::ProhibitMixedBooleanOperators] [ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters] [ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator] [ValuesAndExpressions::RequireQuotedHeredocTerminator] [Variables::ProhibitAugmentedAssignmentInDeclaration] allow_our = 1 [Variables::ProhibitConditionalDeclarations] [Variables::ProhibitMatchVars] [Variables::ProhibitReusedNames] [Variables::ProhibitUnusedVariables] [Variables::ProtectPrivateVars] [Variables::RequireLexicalLoopIterators] [Variables::RequireLocalizedPunctuationVars] allow = $^H %^H ${^WARNING_BITS} ${^OPEN} [Variables::RequireNegativeIndices] Module-Runtime-0.018/Changes000644 000000 000000 00000015175 15001433104 015641 0ustar00rootroot000000 000000 Revision history for Module-Runtime 0.018 2025-04-21 - avoid xattr headers in release tarball - minor code reformatting 0.017 2025-04-06 - fixed internal Pod links - various internal formatting changes - check for eval failures via return value, not $@ - update packaging to remove Module::Build and set x_static_install - removed broken SIGNATURE file 0.016 2017-10-17 - port t/taint.t to Perl 5.27.5, where re-requiring an already-loaded module doesn't trigger tainting - skip t/taint.t if the perl empirically doesn't perform taint checks but the script got run anyway (which happens with an unsupported configuration of the Perl core which some people are using in the absence of a supported no-taint configuration) - in t/taint.t, use $^X rather than $ENV{PATH} as the primordial tainted value to taint a string being tested - in documentation, use four-column indentation for all verbatim material - in META.{yml,json}, point to public bug tracker - in META.json, specify type of public repository 0.015 2017-07-16 - update test suite to not rely on . in @INC, which is no longer necessarily there from Perl 5.25.7 - in documentation, warn about the security problem with use_package_optimistically() - declare correct version for Test::More dependency - generate "traditional" style of compatibility Makefile.PL, to permit building in environments that don't support Build.PL or configure_requires 0.014 2014-02-06 - bugfix: suppress any CORE::GLOBAL::require override, where possible, to avoid use_package_optimistically() being misled into treating missing modules as broken - bugfix: in use_module() and use_package_optimistically(), pass a supplied VERSION parameter through for the version check even if it is undef - tighten use_package_optimistically()'s recognition of can't-locate errors (the same way that base.pm has recently been tightened), so that, when a module fails to load because a module that it uses isn't available, the outer module will be perceived as broken rather than missing - update documentation notes about the state of Unicode handling for module names - in META.{yml,json}, point to public git repository 0.013 2012-02-16 - fix false failure of the test for lack of unintended dependencies that occurred on systems using a sitecustomize.pl 0.012 2012-02-12 - work around Perl core bug [perl #68590] regarding leakage of %^H into modules being loaded - work around Perl core bug that made a failed module loading appear successful when re-requiring the same module - duplicate is_string() from Params::Classify, rather than importing it, to avoid circular dependency problems (affecting both installation and runtime) - duplicate minimal exporting behaviour from Exporter, and avoid using the "feature", "warnings", "strict", and "parent" pragmata, to allow for possible future use of this module by any infrastructure module - document core bug workarounds - document module name syntax more prominently, and discuss the state of Unicode handling - tweak documentation of use_package_optimistically() - test behaviour with tainted module name - test lack of unwanted eval frame around require - give test modules more meaningful names - convert .cvsignore to .gitignore 0.011 2011-10-24 - bugfix: in require_module() and use_module(), work around a Perl core bug affecting Perl 5.8 and 5.10 that could pass the wrong context to the file scope of a required file, which breaks some modules; this bug would only rarely afflict the core's require() in situations where it would afflict require_module() 0.010 2011-10-07 - bugfix: in use_package_optimistically(), fix regexp interpolation that broke operation if the module was loaded from a path containing metacharacters 0.009 2011-10-04 - new function module_notional_filename() - simplify behaviour of use_package_optimistically() to match simplified base.pm 2.18 0.008 2011-05-16 - change usage of Params::Classify functions to take advantage of custom ops in Params::Classify 0.012 - use full stricture in test suite - in Build.PL, complete declaration of configure-time requirements - explicitly state version required of Params::Classify - include META.json in distribution - add MYMETA.json and MYMETA.yml to .cvsignore 0.007 2010-03-19 - add "check_" functions for argument checking - supply regexps to check module name and spec syntax - in "is_" functions, also cleanly handle non-string arguments - in require_module() (also affecting use_module()), call require() as a function (with appropriate name translation) instead of using string eval, to avoid unnecessary complication of exception handling - provide the "is_valid_" functions under shorter "is_" names - revise POD markup - check for required Perl version at runtime - in tests, supply test modules to avoid requiring unrelated math modules - in Build.PL, explicitly declare configure-time requirements - remove bogus "exit 0" from Build.PL 0.006 2009-05-19 - bugfix: avoid unreliable "\w" in regexps in code - document that module name syntax is restricted to ASCII - use simpler "parent" pragma in place of "base" - in documentation, use the term "truth value" instead of the less precise "boolean" - use full stricture in Build.PL 0.005 2007-09-17 - bugfix: override any ambient $SIG{__DIE__} handler when using eval { } - use "base" pragma to import Exporter behaviour - test POD syntax and coverage, and rename an internal function to satisfy the coverage test - build with Module::Build instead of ExtUtils::MakeMaker - complete dependency list - include signature in distribution - in documentation, separate "license" section from "copyright" section 0.004 2007-08-12 - change choice of module to test use_package_optimistically(), because some old versions of Math::BigInt don't have a version number which was causing a false test failure 0.003 2007-01-27 - loosen tests to work with perl v5.9's changed diagnostics 0.002 2006-06-15 - new function use_package_optimistically() to duplicate the "base" pragma's quiet module loading - insert missing bracket in documentation for use_module() 0.001 2004-10-29 - new function use_module() - document return value of require_module() - more stringent tests for the return value of require_module() - explicitly declare lack of module dependencies in Makefile.PL - include Changes file 0.000 2004-02-15 - initial released version Module-Runtime-0.018/LICENSE000644 000000 000000 00000046473 15001433104 015360 0ustar00rootroot000000 000000 This software is copyright (c) 2025 by Andrew Main, Graham Knop. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2025 by Andrew Main, Graham Knop. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2025 by Andrew Main, Graham Knop. This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Module-Runtime-0.018/MANIFEST000644 000000 000000 00000001412 15001433104 015464 0ustar00rootroot000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. .perlcriticrc Changes LICENSE MANIFEST META.json META.yml Makefile.PL README TODO dist.ini lib/Module/Runtime.pm prereqs.yml t/cmn.t t/dependency.t t/import_error.t t/ivmn.t t/ivms.t t/lib/t/Break.pm t/lib/t/Context.pm t/lib/t/Eval.pm t/lib/t/Hints.pm t/lib/t/Nest0.pm t/lib/t/Nest1.pm t/lib/t/Simple.pm t/mnf.t t/rm.t t/taint.t t/um.t t/upo.t t/upo_overridden.t weaver.ini xt/author/cpan-changes.t xt/author/critic.t xt/author/distmeta.t xt/author/eol.t xt/author/kwalitee.t xt/author/minimum-version.t xt/author/mojibake.t xt/author/no-tabs.t xt/author/pod-coverage.t xt/author/pod-spell.t xt/author/pod-syntax.t xt/author/portability.t xt/author/test-version.t xt/release/changes_has_content.t Module-Runtime-0.018/META.json000644 000000 000000 00000004215 15001433104 015760 0ustar00rootroot000000 000000 { "abstract" : "runtime module handling", "author" : [ "Andrew Main (Zefram) " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Module-Runtime", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta" : "0", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::MinimumVersion" : "0", "Test::Mojibake" : "0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage::TrustMe" : "0.002001", "Test::Portability::Files" : "0", "Test::Spelling" : "0.17", "Test::Version" : "1" } }, "runtime" : { "requires" : { "perl" : "5.006000" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "provides" : { "Module::Runtime" : { "file" : "lib/Module/Runtime.pm", "version" : "0.018" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Module-Runtime@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Module-Runtime" }, "repository" : { "type" : "git", "url" : "https://github.com/haarg/Module-Runtime.git", "web" : "https://github.com/haarg/Module-Runtime" } }, "version" : "0.018", "x_contributors" : [ "Graham Knop " ], "x_generated_by_perl" : "v5.40.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.39", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1, "x_use_unsafe_inc" : 0 } Module-Runtime-0.018/META.yml000644 000000 000000 00000001613 15001433104 015607 0ustar00rootroot000000 000000 --- abstract: 'runtime module handling' author: - 'Andrew Main (Zefram) ' build_requires: Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Module-Runtime provides: Module::Runtime: file: lib/Module/Runtime.pm version: '0.018' requires: perl: '5.006000' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Module-Runtime repository: https://github.com/haarg/Module-Runtime.git version: '0.018' x_contributors: - 'Graham Knop ' x_generated_by_perl: v5.40.0 x_serialization_backend: 'YAML::Tiny version 1.76' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_static_install: 1 x_use_unsafe_inc: 0 Module-Runtime-0.018/Makefile.PL000644 000000 000000 00000001743 15001433104 016314 0ustar00rootroot000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; use 5.006000; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "runtime module handling", "AUTHOR" => "Andrew Main (Zefram) ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Module-Runtime", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006000", "NAME" => "Module::Runtime", "PREREQ_PM" => {}, "TEST_REQUIRES" => { "Test::More" => 0 }, "VERSION" => "0.018", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Test::More" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Module-Runtime-0.018/README000644 000000 000000 00000032564 15001433104 015227 0ustar00rootroot000000 000000 NAME Module::Runtime - runtime module handling SYNOPSIS use Module::Runtime qw( $module_name_rx is_module_name check_module_name module_notional_filename require_module); if($module_name =~ /\A$module_name_rx\z/o) { ... if(is_module_name($module_name)) { ... check_module_name($module_name); $notional_filename = module_notional_filename($module_name); require_module($module_name); use Module::Runtime qw(use_module use_package_optimistically); $bi = use_module("Math::BigInt", 1.31)->new("1_234"); $widget = use_package_optimistically("Local::Widget")->new; use Module::Runtime qw( $top_module_spec_rx $sub_module_spec_rx is_module_spec check_module_spec compose_module_name); if($spec =~ /\A$top_module_spec_rx\z/o) { ... if($spec =~ /\A$sub_module_spec_rx\z/o) { ... if(is_module_spec("Standard::Prefix", $spec)) { ... check_module_spec("Standard::Prefix", $spec); $module_name = compose_module_name("Standard::Prefix", $spec); DESCRIPTION The functions exported by this module deal with runtime handling of Perl modules, which are normally handled at compile time. This module avoids using any other modules, so that it can be used in low-level infrastructure. The parts of this module that work with module names apply the same syntax that is used for barewords in Perl source. In principle this syntax can vary between versions of Perl, and this module applies the syntax of the Perl on which it is running. In practice the usable syntax hasn't changed yet. There's some intent for Unicode module names to be supported in the future, but this hasn't yet amounted to any consistent facility. The functions of this module whose purpose is to load modules include workarounds for three old Perl core bugs regarding "require". These workarounds are applied on any Perl version where the bugs exist, except for a case where one of the bugs cannot be adequately worked around in pure Perl. Module name syntax The usable module name syntax has not changed from Perl 5.000 up to Perl 5.19.8. The syntax is composed entirely of ASCII characters. From Perl 5.6 onward there has been some attempt to allow the use of non-ASCII Unicode characters in Perl source, but it was fundamentally broken (like the entirety of Perl 5.6's Unicode handling) and remained pretty much entirely unusable until it got some attention in the Perl 5.15 series. Although Unicode is now consistently accepted by the parser in some places, it remains broken for module names. Furthermore, there has not yet been any work on how to map Unicode module names into filenames, so in that respect also Unicode module names are unusable. The module name syntax is, precisely: the string must consist of one or more segments separated by "::"; each segment must consist of one or more identifier characters (ASCII alphanumerics plus "_"); the first character of the string must not be a digit. Thus ""IO::File"", ""warnings"", and ""foo::123::x_0"" are all valid module names, whereas ""IO::"" and ""1foo::bar"" are not. "'" separators are not permitted by this module, though they remain usable in Perl source, being translated to "::" in the parser. Core bugs worked around The first bug worked around is core bug [perl #68590], which causes lexical state in one file to leak into another that is "require"d/"use"d from it. This bug is present from Perl 5.6 up to Perl 5.10, and is fixed in Perl 5.11.0. From Perl 5.9.4 up to Perl 5.10.0 no satisfactory workaround is possible in pure Perl. The workaround means that modules loaded via this module don't suffer this pollution of their lexical state. Modules loaded in other ways, or via this module on the Perl versions where the pure Perl workaround is impossible, remain vulnerable. The module Lexical::SealRequireHints provides a complete workaround for this bug. The second bug worked around causes some kinds of failure in module loading, principally compilation errors in the loaded module, to be recorded in %INC as if they were successful, so later attempts to load the same module immediately indicate success. This bug is present up to Perl 5.8.9, and is fixed in Perl 5.9.0. The workaround means that a compilation error in a module loaded via this module won't be cached as a success. Modules loaded in other ways remain liable to produce bogus %INC entries, and if a bogus entry exists then it will mislead this module if it is used to re-attempt loading. The third bug worked around causes the wrong context to be seen at file scope of a loaded module, if "require" is invoked in a location that inherits context from a higher scope. This bug is present up to Perl 5.11.2, and is fixed in Perl 5.11.3. The workaround means that a module loaded via this module will always see the correct context. Modules loaded in other ways remain vulnerable. REGULAR EXPRESSIONS These regular expressions do not include any anchors, so to check whether an entire string matches a syntax item you must supply the anchors yourself. $module_name_rx Matches a valid Perl module name in bareword syntax. $top_module_spec_rx Matches a module specification for use with "compose_module_name". where no prefix is being used. $sub_module_spec_rx Matches a module specification for use with "compose_module_name", where a prefix is being used. FUNCTIONS Basic module handling is_module_name(ARG) Returns a truth value indicating whether *ARG* is a plain string satisfying Perl module name syntax as described for "$module_name_rx". is_valid_module_name(ARG) Deprecated alias for "is_module_name". check_module_name(ARG) Check whether *ARG* is a plain string satisfying Perl module name syntax as described for "$module_name_rx". Return normally if it is, or "die" if it is not. module_notional_filename(NAME) Generates a notional relative filename for a module, which is used in some Perl core interfaces. The *NAME* is a string, which should be a valid module name (one or more "::"-separated segments). If it is not a valid name, the function "die"s. The notional filename for the named module is generated and returned. This filename is always in Unix style, with "/" directory separators and a ".pm" suffix. This kind of filename can be used as an argument to "require", and is the key that appears in %INC to identify a module, regardless of actual local filename syntax. require_module(NAME) This is essentially the bareword form of "require", in runtime form. The *NAME* is a string, which should be a valid module name (one or more "::"-separated segments). If it is not a valid name, the function "die"s. The module specified by *NAME* is loaded, if it hasn't been already, in the manner of the bareword form of "require". That means that a search through @INC is performed, and a byte-compiled form of the module will be used if available. The return value is as for "require". That is, it is the value returned by the module itself if the module is loaded anew, or 1 if the module was already loaded. Structured module use use_module(NAME[, VERSION]) This is essentially "use" in runtime form, but without the importing feature (which is fundamentally a compile-time thing). The *NAME* is handled just like in "require_module" above: it must be a module name, and the named module is loaded as if by the bareword form of "require". If a *VERSION* is specified, the "VERSION" method of the loaded module is called with the specified *VERSION* as an argument. This normally serves to ensure that the version loaded is at least the version required. This is the same functionality provided by the *VERSION* parameter of "use". On success, the name of the module is returned. This is unlike "require_module", and is done so that the entire call to "use_module" can be used as a class name to call a constructor, as in the example in the synopsis. use_package_optimistically(NAME[, VERSION]) This is an analogue of "use_module" for the situation where there is uncertainty as to whether a package/class is defined in its own module or by some other means. It attempts to arrange for the named package to be available, either by loading a module or by doing nothing and hoping. An attempt is made to load the named module (as if by the bareword form of "require"). If the module cannot be found then it is assumed that the package was actually already loaded by other means, and no error is signaled. That's the optimistic bit. *Warning:* this optional module loading is liable to cause unreliable behaviour, including security problems. It interacts especially badly with having "." in @INC, which was the default state of affairs in Perls prior to 5.25.11. If a package is actually defined by some means other than a module, then applying this function to it causes a spurious attempt to load a module that is expected to be non-existent. If a module actually exists under that name then it will be unintentionally loaded. If "." is in @INC and this code is ever run with the current directory being one writable by a malicious user (such as /tmp), then the malicious user can easily cause the victim to run arbitrary code, by creating a module file under the predictable spuriously-loaded name in the writable directory. Generally, optional module loading should be avoided. This is mostly the same operation that is performed by the base pragma to ensure that the specified base classes are available. The behaviour of base was simplified in version 2.18, and later improved in version 2.20, and on both occasions this function changed to match. If a *VERSION* is specified, the "VERSION" method of the loaded package is called with the specified *VERSION* as an argument. This normally serves to ensure that the version loaded is at least the version required. On success, the name of the package is returned. These aspects of the function work just like "use_module". Module name composition is_module_spec(PREFIX, SPEC) Returns a truth value indicating whether *SPEC* is valid input for "compose_module_name". See below for what that entails. Whether a *PREFIX* is supplied affects the validity of *SPEC*, but the exact value of the prefix is unimportant, so this function treats *PREFIX* as a truth value. is_valid_module_spec(PREFIX, SPEC) Deprecated alias for "is_module_spec". check_module_spec(PREFIX, SPEC) Check whether *SPEC* is valid input for "compose_module_name". Return normally if it is, or "die" if it is not. compose_module_name(PREFIX, SPEC) This function is intended to make it more convenient for a user to specify a Perl module name at runtime. Users have greater need for abbreviations and context-sensitivity than programmers, and Perl module names get a little unwieldy. *SPEC* is what the user specifies, and this function translates it into a module name in standard form, which it returns. *SPEC* has syntax approximately that of a standard module name: it should consist of one or more name segments, each of which consists of one or more identifier characters. However, "/" is permitted as a separator, in addition to the standard "::". The two separators are entirely interchangeable. Additionally, if *PREFIX* is not "undef" then it must be a module name in standard form, and it is prefixed to the user-specified name. The user can inhibit the prefix addition by starting *SPEC* with a separator (either "/" or "::"). BUGS On Perl versions 5.7.2 to 5.8.8, if "require" is overridden by the "CORE::GLOBAL" mechanism, it is likely to break the heuristics used by "use_package_optimistically", making it signal an error for a missing module rather than assume that it was already loaded. From Perl 5.8.9 onward, and on 5.7.1 and earlier, this module can avoid being confused by such an override. On the affected versions, a "require" override might be installed by Lexical::SealRequireHints, if something requires its bugfix but for some reason its XS implementation isn't available. SEE ALSO * Lexical::SealRequireHints * base * "require" in perlfunc * "use" in perlfunc AUTHOR Andrew Main (Zefram) COPYRIGHT Copyright (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012, 2014, 2017 Andrew Main (Zefram) Copyright (C) 2025 Graham Knop LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Module-Runtime-0.018/TODO000644 000000 000000 00000000340 15001433104 015022 0ustar00rootroot000000 000000 * make buildable via the Build.PL protocol without non-core deps such as MB * wishlist: should have something akin to compose_module_name that supports the evolved pseudostandard syntax used by DBIx::Class, Catalyst, Moose Module-Runtime-0.018/dist.ini000644 000000 000000 00000004407 15001433104 016006 0ustar00rootroot000000 000000 name = Module-Runtime author = Andrew Main (Zefram) license = Perl_5 copyright_holder = Andrew Main, Graham Knop copyright_year = 2025 [%Mint] provider = Author::HAARG profile = default ;;; Gather [Git::GatherDir] exclude_filename = Makefile.PL exclude_filename = META.json exclude_filename = LICENSE exclude_filename = README.md [GatherFile] filename = .perlcriticrc ;;; Metadata [Git::Contributors] [MetaProvides::Package] [MetaResources] bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=Module-Runtime bugtracker.mailto = bug-Module-Runtime@rt.cpan.org repository.url = https://github.com/haarg/Module-Runtime.git repository.web = https://github.com/haarg/Module-Runtime repository.type = git [PrereqsFile] [UseUnsafeInc] dot_in_INC = 0 ;;; Modification [PodWeaver] ; authordep Pod::Weaver::Section::Contributors ; authordep Pod::Weaver::Plugin::StopWords ;;; Extra Files [License] [MetaJSON] [MetaYAML] [Manifest] [Pod2Readme] ;;; Installer [MakeMaker] [StaticInstall] mode = on ;;; Tests [MetaTests] [MojibakeTests] [PodSyntaxTests] [Test::CPAN::Changes] :version = 0.013 filename = xt/author/cpan-changes.t [Test::ChangesHasContent] ;[Test::Compile] ; only one module, don't need to test in isolation [Test::EOL] [Test::Kwalitee] filename = xt/author/kwalitee.t skiptest = use_strict [Test::MinimumVersion] [Test::NoTabs] [Test::Perl::Critic] :version = 3.003 profile = .perlcriticrc verbose = 8 [Test::Pod::Coverage::TrustMe] [Test::PodSpelling] [Test::Portability] options = test_one_dot = 0 ;[Test::ReportPrereqs] ; we have no prereqs [Test::Version] ;;; Repo files [CopyFilesFromRelease] filename = Makefile.PL filename = META.json filename = LICENSE [ReadmeAnyFromPod / ReadmeGFMInRoot] phase = release [Regenerate::AfterReleasers] plugin = CopyFilesFromRelease plugin = ReadmeGFMInRoot ;;; Release [Libarchive] [TestRelease] [RunExtraTests] [ConfirmRelease] [UploadToCPAN] [Git::Check] [Git::Remote::Check] branch = master [@Git::VersionManager] -remove = Prereqs commit_files_after_release = Makefile.PL commit_files_after_release = META.json commit_files_after_release = LICENSE commit_files_after_release = README.md NextRelease.format = %-6v %{yyyy-MM-dd}d%{ (TRIAL RELEASE)}T [Git::Push] Module-Runtime-0.018/lib/000755 000000 000000 00000000000 15001433104 015103 5ustar00rootroot000000 000000 Module-Runtime-0.018/lib/Module/000755 000000 000000 00000000000 15001433104 016330 5ustar00rootroot000000 000000 Module-Runtime-0.018/lib/Module/Runtime.pm000644 000000 000000 00000044332 15001433104 020317 0ustar00rootroot000000 000000 package Module::Runtime; # Don't "use 5.006" here, because Perl 5.15.6 will load feature.pm if # the version check is done that way. BEGIN { require 5.006; } # Don't "use warnings" here, to avoid dependencies. Do standardise the # warning status by lexical override; unfortunately the only safe bitset # to build in is the empty set, equivalent to "no warnings". BEGIN { ${^WARNING_BITS} = ""; } # Don't "use strict" here, to avoid dependencies. our $VERSION = '0.018'; # Don't use Exporter here, to avoid dependencies. our @EXPORT_OK = qw( $module_name_rx is_module_name is_valid_module_name check_module_name module_notional_filename require_module use_module use_package_optimistically $top_module_spec_rx $sub_module_spec_rx is_module_spec is_valid_module_spec check_module_spec compose_module_name ); my %export_ok = map { ($_ => undef) } @EXPORT_OK; sub import { my $me = shift; my $callpkg = caller; my $errs = ""; foreach(@_) { if(exists $export_ok{$_}) { # We would need to do "no strict 'refs'" here # if we had enabled strict at file scope. if(/\A\$(.*)\z/s) { *{$callpkg."::".$1} = \$$1; } else { *{$callpkg."::".$_} = \&$_; } } else { $errs .= "\"$_\" is not exported by the $me module\n"; } } if($errs ne "") { die sprintf "%sCan't continue after import errors at %s line %u.\n", $errs, (caller)[1,2]; } } # Logic duplicated from Params::Classify. Duplicating it here avoids # an extensive and potentially circular dependency graph. sub _is_string($) { my($arg) = @_; return defined($arg) && ref(\$arg) eq "SCALAR"; } our $module_name_rx = qr{[A-Z_a-z][0-9A-Z_a-z]*(?:::[0-9A-Z_a-z]+)*}; my $qual_module_spec_rx = qr{(?:/|::)[A-Z_a-z][0-9A-Z_a-z]*(?:(?:/|::)[0-9A-Z_a-z]+)*}; my $unqual_top_module_spec_rx = qr{[A-Z_a-z][0-9A-Z_a-z]*(?:(?:/|::)[0-9A-Z_a-z]+)*}; our $top_module_spec_rx = qr{$qual_module_spec_rx|$unqual_top_module_spec_rx}; my $unqual_sub_module_spec_rx = qr{[0-9A-Z_a-z]+(?:(?:/|::)[0-9A-Z_a-z]+)*}; our $sub_module_spec_rx = qr{$qual_module_spec_rx|$unqual_sub_module_spec_rx}; sub is_module_name($) { _is_string($_[0]) && $_[0] =~ /\A$module_name_rx\z/o } *is_valid_module_name = \&is_module_name; sub check_module_name($) { unless(&is_module_name) { die +(_is_string($_[0]) ? "`$_[0]'" : "argument"). " is not a module name\n"; } } sub module_notional_filename($) { &check_module_name; my($name) = @_; $name =~ s{::}{/}g; return $name.".pm"; } # Don't "use constant" here, to avoid dependencies. BEGIN { ## no critic (ValuesAndExpressions::ProhibitMismatchedOperators) *_WORK_AROUND_HINT_LEAKAGE = "$]" < 5.011 && !("$]" >= 5.009004 && "$]" < 5.010001) ? sub(){1} : sub(){0}; *_WORK_AROUND_BROKEN_MODULE_STATE = "$]" < 5.009 ? sub(){1} : sub(){0}; } BEGIN { if(_WORK_AROUND_BROKEN_MODULE_STATE) { eval <<'END_CODE' or die $@; ## no critic (BuiltinFunctions::ProhibitStringyEval) sub Module::Runtime::__GUARD__::DESTROY { delete $INC{$_[0]->[0]} if @{$_[0]}; } 1; END_CODE } } sub require_module($) { # Localise %^H to work around [perl #68590], where the bug exists # and this is a satisfactory workaround. The bug consists of # %^H state leaking into each required module, polluting the # module's lexical state. local %^H if _WORK_AROUND_HINT_LEAKAGE; if(_WORK_AROUND_BROKEN_MODULE_STATE) { my $notional_filename = &module_notional_filename; my $guard = bless([ $notional_filename ], "Module::Runtime::__GUARD__"); my $result = CORE::require($notional_filename); pop @$guard; return $result; } else { return scalar(CORE::require(&module_notional_filename)); } } sub use_module($;$) { my($name, $version) = @_; require_module($name); $name->VERSION($version) if @_ >= 2; return $name; } my $FILE = __FILE__; sub use_package_optimistically($;$) { my($name, $version) = @_; my $fn = module_notional_filename($name); eval { local $SIG{__DIE__}; require_module($name); 1; } or do { die $@ if ( $@ !~ /\ACan't locate \Q$fn\E .+ at \Q$FILE\E line/s || $@ =~ /^Compilation\ failed\ in\ require\ at\ \Q$FILE\E\ line/xm ); }; $name->VERSION($version) if @_ >= 2; return $name; } sub is_module_spec($$) { my($prefix, $spec) = @_; return _is_string($spec) && ( $prefix ? $spec =~ /\A$sub_module_spec_rx\z/o : $spec =~ /\A$top_module_spec_rx\z/o ); } *is_valid_module_spec = \&is_module_spec; sub check_module_spec($$) { unless(&is_module_spec) { die +(_is_string($_[1]) ? "`$_[1]'" : "argument"). " is not a module specification\n"; } } sub compose_module_name($$) { my($prefix, $spec) = @_; check_module_name($prefix) if defined $prefix; &check_module_spec; if($spec =~ s{\A(?:/|::)}{}) { # OK } else { $spec = $prefix."::".$spec if defined $prefix; } $spec =~ s{/}{::}g; return $spec; } 1; __END__ =pod =encoding UTF-8 =for :stopwords Andrew Main (Zefram) Main, Graham Knop =head1 NAME Module::Runtime - runtime module handling =head1 SYNOPSIS use Module::Runtime qw( $module_name_rx is_module_name check_module_name module_notional_filename require_module); if($module_name =~ /\A$module_name_rx\z/o) { ... if(is_module_name($module_name)) { ... check_module_name($module_name); $notional_filename = module_notional_filename($module_name); require_module($module_name); use Module::Runtime qw(use_module use_package_optimistically); $bi = use_module("Math::BigInt", 1.31)->new("1_234"); $widget = use_package_optimistically("Local::Widget")->new; use Module::Runtime qw( $top_module_spec_rx $sub_module_spec_rx is_module_spec check_module_spec compose_module_name); if($spec =~ /\A$top_module_spec_rx\z/o) { ... if($spec =~ /\A$sub_module_spec_rx\z/o) { ... if(is_module_spec("Standard::Prefix", $spec)) { ... check_module_spec("Standard::Prefix", $spec); $module_name = compose_module_name("Standard::Prefix", $spec); =head1 DESCRIPTION The functions exported by this module deal with runtime handling of Perl modules, which are normally handled at compile time. This module avoids using any other modules, so that it can be used in low-level infrastructure. The parts of this module that work with module names apply the same syntax that is used for barewords in Perl source. In principle this syntax can vary between versions of Perl, and this module applies the syntax of the Perl on which it is running. In practice the usable syntax hasn't changed yet. There's some intent for Unicode module names to be supported in the future, but this hasn't yet amounted to any consistent facility. The functions of this module whose purpose is to load modules include workarounds for three old Perl core bugs regarding C. These workarounds are applied on any Perl version where the bugs exist, except for a case where one of the bugs cannot be adequately worked around in pure Perl. =head2 Module name syntax The usable module name syntax has not changed from Perl 5.000 up to Perl 5.19.8. The syntax is composed entirely of ASCII characters. From Perl 5.6 onward there has been some attempt to allow the use of non-ASCII Unicode characters in Perl source, but it was fundamentally broken (like the entirety of Perl 5.6's Unicode handling) and remained pretty much entirely unusable until it got some attention in the Perl 5.15 series. Although Unicode is now consistently accepted by the parser in some places, it remains broken for module names. Furthermore, there has not yet been any work on how to map Unicode module names into filenames, so in that respect also Unicode module names are unusable. The module name syntax is, precisely: the string must consist of one or more segments separated by C<::>; each segment must consist of one or more identifier characters (ASCII alphanumerics plus "_"); the first character of the string must not be a digit. Thus "C", "C", and "C" are all valid module names, whereas "C" and "C<1foo::bar>" are not. C<'> separators are not permitted by this module, though they remain usable in Perl source, being translated to C<::> in the parser. =head2 Core bugs worked around The first bug worked around is core bug [perl #68590], which causes lexical state in one file to leak into another that is Cd/Cd from it. This bug is present from Perl 5.6 up to Perl 5.10, and is fixed in Perl 5.11.0. From Perl 5.9.4 up to Perl 5.10.0 no satisfactory workaround is possible in pure Perl. The workaround means that modules loaded via this module don't suffer this pollution of their lexical state. Modules loaded in other ways, or via this module on the Perl versions where the pure Perl workaround is impossible, remain vulnerable. The module L provides a complete workaround for this bug. The second bug worked around causes some kinds of failure in module loading, principally compilation errors in the loaded module, to be recorded in C<%INC> as if they were successful, so later attempts to load the same module immediately indicate success. This bug is present up to Perl 5.8.9, and is fixed in Perl 5.9.0. The workaround means that a compilation error in a module loaded via this module won't be cached as a success. Modules loaded in other ways remain liable to produce bogus C<%INC> entries, and if a bogus entry exists then it will mislead this module if it is used to re-attempt loading. The third bug worked around causes the wrong context to be seen at file scope of a loaded module, if C is invoked in a location that inherits context from a higher scope. This bug is present up to Perl 5.11.2, and is fixed in Perl 5.11.3. The workaround means that a module loaded via this module will always see the correct context. Modules loaded in other ways remain vulnerable. =head1 REGULAR EXPRESSIONS These regular expressions do not include any anchors, so to check whether an entire string matches a syntax item you must supply the anchors yourself. =over =item $module_name_rx Matches a valid Perl module name in bareword syntax. =item $top_module_spec_rx Matches a module specification for use with L<"compose_module_name"|/compose_module_name(PREFIX, SPEC)>. where no prefix is being used. =item $sub_module_spec_rx Matches a module specification for use with L<"compose_module_name"|/compose_module_name(PREFIX, SPEC)>, where a prefix is being used. =back =head1 FUNCTIONS =head2 Basic module handling =over =item is_module_name(ARG) Returns a truth value indicating whether I is a plain string satisfying Perl module name syntax as described for L. =item is_valid_module_name(ARG) Deprecated alias for L<"is_module_name"|/is_module_name(ARG)>. =item check_module_name(ARG) Check whether I is a plain string satisfying Perl module name syntax as described for L. Return normally if it is, or C if it is not. =item module_notional_filename(NAME) Generates a notional relative filename for a module, which is used in some Perl core interfaces. The I is a string, which should be a valid module name (one or more C<::>-separated segments). If it is not a valid name, the function Cs. The notional filename for the named module is generated and returned. This filename is always in Unix style, with C directory separators and a C<.pm> suffix. This kind of filename can be used as an argument to C, and is the key that appears in C<%INC> to identify a module, regardless of actual local filename syntax. =item require_module(NAME) This is essentially the bareword form of C, in runtime form. The I is a string, which should be a valid module name (one or more C<::>-separated segments). If it is not a valid name, the function Cs. The module specified by I is loaded, if it hasn't been already, in the manner of the bareword form of C. That means that a search through C<@INC> is performed, and a byte-compiled form of the module will be used if available. The return value is as for C. That is, it is the value returned by the module itself if the module is loaded anew, or C<1> if the module was already loaded. =back =head2 Structured module use =over =item use_module(NAME[, VERSION]) This is essentially C in runtime form, but without the importing feature (which is fundamentally a compile-time thing). The I is handled just like in C above: it must be a module name, and the named module is loaded as if by the bareword form of C. If a I is specified, the C method of the loaded module is called with the specified I as an argument. This normally serves to ensure that the version loaded is at least the version required. This is the same functionality provided by the I parameter of C. On success, the name of the module is returned. This is unlike L<"require_module"|/require_module(NAME)>, and is done so that the entire call to L<"use_module"|/use_module(NAME[, VERSION])> can be used as a class name to call a constructor, as in the example in the synopsis. =item use_package_optimistically(NAME[, VERSION]) This is an analogue of L<"use_module"|/use_module(NAME[, VERSION])> for the situation where there is uncertainty as to whether a package/class is defined in its own module or by some other means. It attempts to arrange for the named package to be available, either by loading a module or by doing nothing and hoping. An attempt is made to load the named module (as if by the bareword form of C). If the module cannot be found then it is assumed that the package was actually already loaded by other means, and no error is signaled. That's the optimistic bit. I this optional module loading is liable to cause unreliable behaviour, including security problems. It interacts especially badly with having C<.> in C<@INC>, which was the default state of affairs in Perls prior to 5.25.11. If a package is actually defined by some means other than a module, then applying this function to it causes a spurious attempt to load a module that is expected to be non-existent. If a module actually exists under that name then it will be unintentionally loaded. If C<.> is in C<@INC> and this code is ever run with the current directory being one writable by a malicious user (such as F), then the malicious user can easily cause the victim to run arbitrary code, by creating a module file under the predictable spuriously-loaded name in the writable directory. Generally, optional module loading should be avoided. This is mostly the same operation that is performed by the L pragma to ensure that the specified base classes are available. The behaviour of L was simplified in version 2.18, and later improved in version 2.20, and on both occasions this function changed to match. If a I is specified, the C method of the loaded package is called with the specified I as an argument. This normally serves to ensure that the version loaded is at least the version required. On success, the name of the package is returned. These aspects of the function work just like L<"use_module"|/use_module(NAME[, VERSION])>. =back =head2 Module name composition =over =item is_module_spec(PREFIX, SPEC) Returns a truth value indicating whether I is valid input for L<"compose_module_name"|/compose_module_name(PREFIX, SPEC)>. See below for what that entails. Whether a I is supplied affects the validity of I, but the exact value of the prefix is unimportant, so this function treats I as a truth value. =item is_valid_module_spec(PREFIX, SPEC) Deprecated alias for L<"is_module_spec"|/is_module_spec(PREFIX, SPEC)>. =item check_module_spec(PREFIX, SPEC) Check whether I is valid input for L<"compose_module_name"|/compose_module_name(PREFIX, SPEC)>. Return normally if it is, or C if it is not. =item compose_module_name(PREFIX, SPEC) This function is intended to make it more convenient for a user to specify a Perl module name at runtime. Users have greater need for abbreviations and context-sensitivity than programmers, and Perl module names get a little unwieldy. I is what the user specifies, and this function translates it into a module name in standard form, which it returns. I has syntax approximately that of a standard module name: it should consist of one or more name segments, each of which consists of one or more identifier characters. However, C is permitted as a separator, in addition to the standard C<::>. The two separators are entirely interchangeable. Additionally, if I is not C then it must be a module name in standard form, and it is prefixed to the user-specified name. The user can inhibit the prefix addition by starting I with a separator (either C or C<::>). =back =head1 BUGS On Perl versions 5.7.2 to 5.8.8, if C is overridden by the C mechanism, it is likely to break the heuristics used by L<"use_package_optimistically"|/use_package_optimistically(NAME[, VERSION])>, making it signal an error for a missing module rather than assume that it was already loaded. From Perl 5.8.9 onward, and on 5.7.1 and earlier, this module can avoid being confused by such an override. On the affected versions, a C override might be installed by L, if something requires its bugfix but for some reason its XS implementation isn't available. =head1 SEE ALSO =over 4 =item * L =item * L =item * L =item * L =back =head1 AUTHOR Andrew Main (Zefram) =head1 COPYRIGHT Copyright (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012, 2014, 2017 Andrew Main (Zefram) Copyright (C) 2025 Graham Knop =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Module-Runtime-0.018/prereqs.yml000644 000000 000000 00000000116 15001433104 016537 0ustar00rootroot000000 000000 runtime: requires: perl: '5.006000' test: requires: Test::More: 0 Module-Runtime-0.018/t/000755 000000 000000 00000000000 15001433104 014600 5ustar00rootroot000000 000000 Module-Runtime-0.018/t/cmn.t000644 000000 000000 00000002032 15001433104 015537 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 17; BEGIN { use_ok "Module::Runtime", qw(compose_module_name); } is(compose_module_name(undef, "foo"), "foo"); is(compose_module_name(undef, "foo::bar"), "foo::bar"); is(compose_module_name(undef, "foo/bar"), "foo::bar"); is(compose_module_name(undef, "foo/bar/baz"), "foo::bar::baz"); is(compose_module_name(undef, "/foo"), "foo"); is(compose_module_name(undef, "/foo::bar"), "foo::bar"); is(compose_module_name(undef, "::foo/bar"), "foo::bar"); is(compose_module_name(undef, "::foo/bar/baz"), "foo::bar::baz"); is(compose_module_name("a::b", "foo"), "a::b::foo"); is(compose_module_name("a::b", "foo::bar"), "a::b::foo::bar"); is(compose_module_name("a::b", "foo/bar"), "a::b::foo::bar"); is(compose_module_name("a::b", "foo/bar/baz"), "a::b::foo::bar::baz"); is(compose_module_name("a::b", "/foo"), "foo"); is(compose_module_name("a::b", "/foo::bar"), "foo::bar"); is(compose_module_name("a::b", "::foo/bar"), "foo::bar"); is(compose_module_name("a::b", "::foo/bar/baz"), "foo::bar::baz"); 1; Module-Runtime-0.018/t/dependency.t000644 000000 000000 00000000651 15001433104 017105 0ustar00rootroot000000 000000 # This test checks that M:R doesn't load any other modules. Hence this # script cannot itself use warnings, Test::More, or any other module. BEGIN { print "1..1\n"; } our(%preloaded, @extraloaded); BEGIN { %preloaded = %INC; } use Module::Runtime qw(require_module); BEGIN { @extraloaded = sort grep { !exists($preloaded{$_}) } keys %INC; } print join(" ", @extraloaded) eq "Module/Runtime.pm" ? "" : "not ", "ok 1\n"; 1; Module-Runtime-0.018/t/import_error.t000644 000000 000000 00000002033 15001433104 017506 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 3; eval q{#line 11 "test_eval" use Module::Runtime qw(foo); }; $@ =~ s/\(eval [0-9]+\) line 2/test_eval line 11/ if "$]" < 5.006001; like $@, qr/\A \"foo\"\ is\ not\ exported\ by\ the\ Module::Runtime\ module\n Can't\ continue\ after\ import\ errors\ at\ test_eval\ line\ 11.\n /x; eval q{#line 22 "test_eval" use Module::Runtime qw(require_module.1); }; $@ =~ s/\(eval [0-9]+\) line 2/test_eval line 22/ if "$]" < 5.006001; like $@, qr/\A \"require_module.1\"\ is\ not\ exported \ by\ the\ Module::Runtime\ module\n Can't\ continue\ after\ import\ errors\ at\ test_eval\ line\ 22.\n /x; eval q{#line 33 "test_eval" use Module::Runtime qw(foo require_module bar); }; $@ =~ s/\(eval [0-9]+\) line 2/test_eval line 33/ if "$]" < 5.006001; like $@, qr/\A \"foo\"\ is\ not\ exported\ by\ the\ Module::Runtime\ module\n \"bar\"\ is\ not\ exported\ by\ the\ Module::Runtime\ module\n Can't\ continue\ after\ import\ errors\ at\ test_eval\ line\ 33.\n /x; 1; Module-Runtime-0.018/t/ivmn.t000644 000000 000000 00000001723 15001433104 015741 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 47; BEGIN { use_ok "Module::Runtime", qw( $module_name_rx is_module_name is_valid_module_name check_module_name ); } ok \&is_valid_module_name == \&is_module_name; foreach my $name ( undef, *STDOUT, \"Foo", [], {}, sub{}, ) { ok(!is_module_name($name), "non-string is bad (function)"); eval { check_module_name($name) }; isnt $@, ""; } foreach my $name (qw( Foo foo::bar IO::File foo::123::x_0 _ )) { ok(is_module_name($name), "`$name' is good (function)"); eval { check_module_name($name) }; is $@, ""; ok($name =~ /\A$module_name_rx\z/, "`$name' is good (regexp)"); } foreach my $name (qw( foo'bar foo/bar IO:: 1foo::bar ::foo foo::::bar )) { ok(!is_module_name($name), "`$name' is bad (function)"); eval { check_module_name($name) }; isnt $@, ""; ok($name !~ /\A$module_name_rx\z/, "`$name' is bad (regexp)"); } 1; Module-Runtime-0.018/t/ivms.t000644 000000 000000 00000004221 15001433104 015742 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 140; BEGIN { use_ok "Module::Runtime", qw( $top_module_spec_rx $sub_module_spec_rx is_module_spec is_valid_module_spec check_module_spec ); } ok \&is_valid_module_spec == \&is_module_spec; foreach my $spec ( undef, *STDOUT, \"Foo", [], {}, sub{}, ) { ok(!is_module_spec(0, $spec), "non-string is bad (function)"); eval { check_module_spec(0, $spec) }; isnt $@, ""; ok(!is_module_spec(1, $spec), "non-string is bad (function)"); eval { check_module_spec(1, $spec) }; isnt $@, ""; } foreach my $spec (qw( Foo foo::bar foo::123::x_0 foo/bar foo/123::x_0 foo::123/x_0 foo/123/x_0 /Foo /foo/bar ::foo/bar )) { ok(is_module_spec(0, $spec), "`$spec' is always good (function)"); eval { check_module_spec(0, $spec) }; is $@, ""; ok($spec =~ qr/\A$top_module_spec_rx\z/, "`$spec' is always good (regexp)"); ok(is_module_spec(1, $spec), "`$spec' is always good (function)"); eval { check_module_spec(1, $spec) }; is $@, ""; ok($spec =~ qr/\A$sub_module_spec_rx\z/, "`$spec' is always good (regexp)"); } foreach my $spec (qw( foo'bar IO:: foo::::bar /foo/ /1foo ::foo:: ::1foo )) { ok(!is_module_spec(0, $spec), "`$spec' is always bad (function)"); eval { check_module_spec(0, $spec) }; isnt $@, ""; ok($spec !~ qr/\A$top_module_spec_rx\z/, "`$spec' is always bad (regexp)"); ok(!is_module_spec(1, $spec), "`$spec' is always bad (function)"); eval { check_module_spec(1, $spec) }; isnt $@, ""; ok($spec !~ qr/\A$sub_module_spec_rx\z/, "`$spec' is always bad (regexp)"); } foreach my $spec (qw( 1foo 0/1 )) { ok(!is_module_spec(0, $spec), "`$spec' needs a prefix (function)"); eval { check_module_spec(0, $spec) }; isnt $@, ""; ok($spec !~ qr/\A$top_module_spec_rx\z/, "`$spec' needs a prefix (regexp)"); ok(is_module_spec(1, $spec), "`$spec' needs a prefix (function)"); eval { check_module_spec(1, $spec) }; is $@, ""; ok($spec =~ qr/\A$sub_module_spec_rx\z/, "`$spec' needs a prefix (regexp)"); } 1; Module-Runtime-0.018/t/lib/000755 000000 000000 00000000000 15001433104 015346 5ustar00rootroot000000 000000 Module-Runtime-0.018/t/lib/t/000755 000000 000000 00000000000 15001433104 015611 5ustar00rootroot000000 000000 Module-Runtime-0.018/t/lib/t/Break.pm000644 000000 000000 00000000113 15001433104 017166 0ustar00rootroot000000 000000 package t::Break; { use 5.006; } use warnings; use strict; die "broken"; Module-Runtime-0.018/t/lib/t/Context.pm000644 000000 000000 00000000363 15001433104 017575 0ustar00rootroot000000 000000 package t::Context; { use 5.006; } use warnings; use strict; our $VERSION = 1; die "t::Context sees array context at file scope" if wantarray; die "t::Context sees void context at file scope" unless defined wantarray; "t::Context return"; Module-Runtime-0.018/t/lib/t/Eval.pm000644 000000 000000 00000001617 15001433104 017043 0ustar00rootroot000000 000000 package t::Eval; use warnings; use strict; use Test::More 0.41; sub _ok_no_eval() { my $lastsub = ""; my $i = 0; while(1) { my @c = caller($i); unless(@c) { ok 0; diag "failed to find main program in stack trace"; return; } my $sub = $c[3]; if($sub eq "main::eval_test") { ok 1; return; } my $type = $sub ne "(eval)" ? "subroutine" : $c[7] ? "require" : defined($c[6]) ? "string eval" : "block eval"; if($type =~ /eval/ && !($lastsub eq "t::Eval::BEGIN" && $type eq "block eval")) { ok 0; diag "have $type between module and main program"; return; } $lastsub = $sub; $i++; } } BEGIN { _ok_no_eval(); } _ok_no_eval(); sub import { _ok_no_eval(); } 1; Module-Runtime-0.018/t/lib/t/Hints.pm000644 000000 000000 00000000473 15001433104 017240 0ustar00rootroot000000 000000 package t::Hints; use warnings; use strict; use Test::More; BEGIN { is $^H{"Module::Runtime/test_a"}, undef; } main::test_runtime_hint_hash "Module::Runtime/test_a", undef; sub import { is $^H{"Module::Runtime/test_a"}, 1; $^H |= 0x20000 if "$]" < 5.009004; $^H{"Module::Runtime/test_b"} = 1; } 1; Module-Runtime-0.018/t/lib/t/Nest0.pm000644 000000 000000 00000000162 15001433104 017137 0ustar00rootroot000000 000000 package t::Nest0; { use 5.006; } use warnings; use strict; use t::Nested; our $VERSION = 1; "t::Nest0 return"; Module-Runtime-0.018/t/lib/t/Nest1.pm000644 000000 000000 00000000251 15001433104 017137 0ustar00rootroot000000 000000 package t::Nest1; { use 5.006; } use warnings; use strict; use Module::Runtime qw(require_module); our $VERSION = 1; require_module("t::Nested"); "t::Nest1 return"; Module-Runtime-0.018/t/lib/t/Simple.pm000644 000000 000000 00000000145 15001433104 017400 0ustar00rootroot000000 000000 package t::Simple; { use 5.006; } use warnings; use strict; our $VERSION = 1; "t::Simple return"; Module-Runtime-0.018/t/mnf.t000644 000000 000000 00000000565 15001433104 015553 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 5; BEGIN { use_ok "Module::Runtime", qw(module_notional_filename); } is module_notional_filename("Test::More"), "Test/More.pm"; is module_notional_filename("Test::More::Widgets"), "Test/More/Widgets.pm"; is module_notional_filename("Foo::0Bar::Baz"), "Foo/0Bar/Baz.pm"; is module_notional_filename("Foo"), "Foo.pm"; 1; Module-Runtime-0.018/t/rm.t000644 000000 000000 00000004510 15001433104 015403 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 26; BEGIN { use_ok "Module::Runtime", qw(require_module); } unshift @INC, "./t/lib"; my($result, $err); sub test_require_module($) { my($name) = @_; $result = eval { require_module($name) }; $err = $@; } # a module that doesn't exist test_require_module("t::NotExist"); like($err, qr/^Can't locate /); # a module that's already loaded test_require_module("Test::More"); is($err, ""); is($result, 1); # a module that we'll load now test_require_module("t::Simple"); is($err, ""); is($result, "t::Simple return"); # re-requiring the module that we just loaded test_require_module("t::Simple"); is($err, ""); is($result, 1); # module file scope sees scalar context regardless of calling context eval { require_module("t::Context"); 1 }; is $@, ""; # lexical hints don't leak through my $have_runtime_hint_hash = "$]" >= 5.009004; sub test_runtime_hint_hash($$) { SKIP: { skip "no runtime hint hash", 1 unless $have_runtime_hint_hash; is +((caller(0))[10] || {})->{$_[0]}, $_[1]; } } SKIP: { skip "core bug makes this test crash", 13 if "$]" >= 5.008 && "$]" < 5.008004; skip "can't work around hint leakage in pure Perl", 13 if "$]" >= 5.009004 && "$]" < 5.010001; $^H |= 0x20000 if "$]" < 5.009004; $^H{"Module::Runtime/test_a"} = 1; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; require_module("t::Hints"); is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; t::Hints->import; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, 1; eval q{ BEGIN { $^H |= 0x20000; $^H{foo} = 1; } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); BEGIN { require_module("Math::BigInt"); } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); 1; }; die $@ unless $@ eq ""; } # broken module is visibly broken when re-required eval { require_module("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; eval { require_module("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; # no extra eval frame SKIP: { skip "core bug makes this test crash", 2 if "$]" < 5.006001; sub eval_test () { require_module("t::Eval") } eval_test(); } 1; Module-Runtime-0.018/t/taint.t000644 000000 000000 00000001421 15001433104 016102 0ustar00rootroot000000 000000 #!perl -T # above line is required to enable taint mode use warnings; use strict; BEGIN { if(eval { eval("1".substr($^X,0,0)) }) { require Test::More; Test::More::plan(skip_all => "tainting not supported on this Perl"); } } use Test::More tests => 5; BEGIN { use_ok "Module::Runtime", qw(require_module use_module use_package_optimistically); } unshift @INC, "./t/lib"; my $tainted_modname = substr($^X, 0, 0) . "t::Simple"; eval { require_module($tainted_modname) }; like $@, qr/\AInsecure dependency /; eval { use_module($tainted_modname) }; like $@, qr/\AInsecure dependency /; eval { use_package_optimistically($tainted_modname) }; like $@, qr/\AInsecure dependency /; eval { require_module("Module::Runtime") }; is $@, ""; 1; Module-Runtime-0.018/t/um.t000644 000000 000000 00000006141 15001433104 015410 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 37; BEGIN { use_ok "Module::Runtime", qw(use_module); } unshift @INC, "./t/lib"; my $result; # a module that doesn't exist $result = eval { use_module("t::NotExist") }; like($@, qr/^Can't locate /); # a module that's already loaded $result = eval { use_module("Test::More") }; is($@, ""); is($result, "Test::More"); # a module that we'll load now $result = eval { use_module("t::Simple") }; is($@, ""); is($result, "t::Simple"); # re-requiring the module that we just loaded $result = eval { use_module("t::Simple") }; is($@, ""); is($result, "t::Simple"); # module file scope sees scalar context regardless of calling context $result = eval { use_module("t::Context"); 1 }; is $@, ""; # lexical hints don't leak through my $have_runtime_hint_hash = "$]" >= 5.009004; sub test_runtime_hint_hash($$) { SKIP: { skip "no runtime hint hash", 1 unless $have_runtime_hint_hash; is +((caller(0))[10] || {})->{$_[0]}, $_[1]; } } SKIP: { skip "core bug makes this test crash", 13 if "$]" >= 5.008 && "$]" < 5.008004; skip "can't work around hint leakage in pure Perl", 13 if "$]" >= 5.009004 && "$]" < 5.010001; $^H |= 0x20000 if "$]" < 5.009004; $^H{"Module::Runtime/test_a"} = 1; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; use_module("t::Hints"); is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; t::Hints->import; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, 1; eval q{ BEGIN { $^H |= 0x20000; $^H{foo} = 1; } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); BEGIN { use_module("Math::BigInt"); } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); 1; }; die $@ unless $@ eq ""; } # broken module is visibly broken when re-required eval { use_module("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; eval { use_module("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; # no extra eval frame SKIP: { skip "core bug makes this test crash", 2 if "$]" < 5.006001; sub eval_test () { use_module("t::Eval") } eval_test(); } # successful version check $result = eval { use_module("Module::Runtime", 0.001) }; is($@, ""); is($result, "Module::Runtime"); # failing version check $result = eval { use_module("Module::Runtime", 999) }; like($@, qr/^Module::Runtime version /); # make sure any version argument gets passed through my @version_calls; sub t::HasVersion::VERSION { push @version_calls, [@_]; } $INC{"t/HasVersion.pm"} = 1; eval { use_module("t::HasVersion") }; is $@, ""; is_deeply \@version_calls, []; @version_calls = (); eval { use_module("t::HasVersion", 2) }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion",2]]; @version_calls = (); eval { use_module("t::HasVersion", "wibble") }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion","wibble"]]; @version_calls = (); eval { use_module("t::HasVersion", undef) }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion",undef]]; 1; Module-Runtime-0.018/t/upo.t000644 000000 000000 00000007414 15001433104 015576 0ustar00rootroot000000 000000 use warnings; use strict; use Test::More tests => 42; BEGIN { use_ok "Module::Runtime", qw(use_package_optimistically); } unshift @INC, "./t/lib"; my $result; # a module that doesn't exist $result = eval { use_package_optimistically("t::NotExist") }; is $@, ""; is $result, "t::NotExist"; # a module that's already loaded $result = eval { use_package_optimistically("Test::More") }; is $@, ""; is $result, "Test::More"; # a module that we'll load now $result = eval { use_package_optimistically("t::Simple") }; is $@, ""; is $result, "t::Simple"; no strict "refs"; ok defined(${"t::Simple::VERSION"}); # lexical hints don't leak through my $have_runtime_hint_hash = "$]" >= 5.009004; sub test_runtime_hint_hash($$) { SKIP: { skip "no runtime hint hash", 1 unless $have_runtime_hint_hash; is +((caller(0))[10] || {})->{$_[0]}, $_[1]; } } SKIP: { skip "core bug makes this test crash", 13 if "$]" >= 5.008 && "$]" < 5.008004; skip "can't work around hint leakage in pure Perl", 13 if "$]" >= 5.009004 && "$]" < 5.010001; $^H |= 0x20000 if "$]" < 5.009004; $^H{"Module::Runtime/test_a"} = 1; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; use_package_optimistically("t::Hints"); is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, undef; t::Hints->import; is $^H{"Module::Runtime/test_a"}, 1; is $^H{"Module::Runtime/test_b"}, 1; eval q{ BEGIN { $^H |= 0x20000; $^H{foo} = 1; } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); BEGIN { use_package_optimistically("Math::BigInt"); } BEGIN { is $^H{foo}, 1; } main::test_runtime_hint_hash("foo", 1); 1; }; die $@ unless $@ eq ""; } # broken module is visibly broken when re-required eval { use_package_optimistically("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; eval { use_package_optimistically("t::Break") }; like $@, qr/\A(?:broken |Attempt to reload )/; # module broken by virtue of trying to non-optimistically load a # non-existent module via "use" eval { use_package_optimistically("t::Nest0") }; like $@, qr/\ACan't locate /; eval { use_package_optimistically("t::Nest0") }; like $@, qr/\A(?:Can't locate |Attempt to reload )/; # module broken by virtue of trying to non-optimistically load a # non-existent module via require_module() eval { use_package_optimistically("t::Nest1") }; like $@, qr/\ACan't locate /; eval { use_package_optimistically("t::Nest1") }; like $@, qr/\A(?:Can't locate |Attempt to reload )/; # successful version check $result = eval { use_package_optimistically("Module::Runtime", 0.001) }; is $@, ""; is $result, "Module::Runtime"; # failing version check $result = eval { use_package_optimistically("Module::Runtime", 999) }; like $@, qr/^Module::Runtime version /; # even load module if $VERSION already set, unlike older behaviour $t::Context::VERSION = undef; $result = eval { use_package_optimistically("t::Context") }; is $@, ""; is $result, "t::Context"; ok defined($t::Context::VERSION); ok $INC{"t/Context.pm"}; # make sure any version argument gets passed through my @version_calls; sub t::HasVersion::VERSION { push @version_calls, [@_]; } $INC{"t/HasVersion.pm"} = 1; eval { use_package_optimistically("t::HasVersion") }; is $@, ""; is_deeply \@version_calls, []; @version_calls = (); eval { use_package_optimistically("t::HasVersion", 2) }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion",2]]; @version_calls = (); eval { use_package_optimistically("t::HasVersion", "wibble") }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion","wibble"]]; @version_calls = (); eval { use_package_optimistically("t::HasVersion", undef) }; is $@, ""; is_deeply \@version_calls, [["t::HasVersion",undef]]; 1; Module-Runtime-0.018/t/upo_overridden.t000644 000000 000000 00000000670 15001433104 020014 0ustar00rootroot000000 000000 use warnings; use strict; if("$]" < 5.007002) { require Test::More; Test::More::plan(skip_all => "require override can't work acceptably on this perl"); } elsif("$]" >= 5.007002 && "$]" < 5.008009) { require Test::More; Test::More::plan(skip_all => "require override can't be dodged on this perl"); } no warnings "once"; *CORE::GLOBAL::require = sub { require $_[0] }; do "./t/upo.t" or die $@ || $!; 1; Module-Runtime-0.018/weaver.ini000644 000000 000000 00000000112 15001433104 016321 0ustar00rootroot000000 000000 [@CorePrep] [-SingleEncoding] [-StopWords] [Generic / NAME] [Leftovers] Module-Runtime-0.018/xt/000755 000000 000000 00000000000 15001433104 014770 5ustar00rootroot000000 000000 Module-Runtime-0.018/xt/author/000755 000000 000000 00000000000 15001433104 016272 5ustar00rootroot000000 000000 Module-Runtime-0.018/xt/author/cpan-changes.t000644 000000 000000 00000000344 15001433104 021007 0ustar00rootroot000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.013 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; Module-Runtime-0.018/xt/author/critic.t000644 000000 000000 00000000210 15001433104 017725 0ustar00rootroot000000 000000 #!perl use strict; use warnings; use Test::Perl::Critic %{+{ "-profile" => ".perlcriticrc", "-verbose" => 8, }}; all_critic_ok(); Module-Runtime-0.018/xt/author/distmeta.t000644 000000 000000 00000000223 15001433104 020266 0ustar00rootroot000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use strict; use warnings; use Test::CPAN::Meta; meta_yaml_ok(); Module-Runtime-0.018/xt/author/eol.t000644 000000 000000 00000001152 15001433104 017235 0ustar00rootroot000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/Module/Runtime.pm', 't/cmn.t', 't/dependency.t', 't/import_error.t', 't/ivmn.t', 't/ivms.t', 't/lib/t/Break.pm', 't/lib/t/Context.pm', 't/lib/t/Eval.pm', 't/lib/t/Hints.pm', 't/lib/t/Nest0.pm', 't/lib/t/Nest1.pm', 't/lib/t/Simple.pm', 't/mnf.t', 't/rm.t', 't/taint.t', 't/um.t', 't/upo.t', 't/upo_overridden.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; Module-Runtime-0.018/xt/author/kwalitee.t000644 000000 000000 00000000320 15001433104 020257 0ustar00rootroot000000 000000 # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok( qw( -use_strict ) ); done_testing; Module-Runtime-0.018/xt/author/minimum-version.t000644 000000 000000 00000000154 15001433104 021615 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; use Test::MinimumVersion; all_minimum_version_from_metayml_ok(); Module-Runtime-0.018/xt/author/mojibake.t000644 000000 000000 00000000151 15001433104 020235 0ustar00rootroot000000 000000 #!perl use strict; use warnings qw(all); use Test::More; use Test::Mojibake; all_files_encoding_ok(); Module-Runtime-0.018/xt/author/no-tabs.t000644 000000 000000 00000001120 15001433104 020014 0ustar00rootroot000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/Module/Runtime.pm', 't/cmn.t', 't/dependency.t', 't/import_error.t', 't/ivmn.t', 't/ivms.t', 't/lib/t/Break.pm', 't/lib/t/Context.pm', 't/lib/t/Eval.pm', 't/lib/t/Hints.pm', 't/lib/t/Nest0.pm', 't/lib/t/Nest1.pm', 't/lib/t/Simple.pm', 't/mnf.t', 't/rm.t', 't/taint.t', 't/um.t', 't/upo.t', 't/upo_overridden.t' ); notabs_ok($_) foreach @files; done_testing; Module-Runtime-0.018/xt/author/pod-coverage.t000644 000000 000000 00000000541 15001433104 021032 0ustar00rootroot000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Test::Pod::Coverage::TrustMe v1.0.1 use strict; use warnings; use Test::More; use Test::Pod::Coverage::TrustMe; my $config = {}; my $modules = [ "Module::Runtime", ]; plan tests => scalar @$modules; for my $module (@$modules) { pod_coverage_ok($module, $config); } done_testing; Module-Runtime-0.018/xt/author/pod-spell.t000644 000000 000000 00000000443 15001433104 020357 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007006 use Test::Spelling 0.17; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ Andrew Graham Knop Main Module Runtime Zefram haarg lib zefram Module-Runtime-0.018/xt/author/pod-syntax.t000644 000000 000000 00000000252 15001433104 020564 0ustar00rootroot000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Module-Runtime-0.018/xt/author/portability.t000644 000000 000000 00000000163 15001433104 021021 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; use Test::Portability::Files; options(test_one_dot => 0); run_tests(); Module-Runtime-0.018/xt/author/test-version.t000644 000000 000000 00000000637 15001433104 021127 0ustar00rootroot000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.09 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 0, has_version => 1, multiple => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; Module-Runtime-0.018/xt/release/000755 000000 000000 00000000000 15001433104 016410 5ustar00rootroot000000 000000 Module-Runtime-0.018/xt/release/changes_has_content.t000644 000000 000000 00000002101 15001433104 022564 0ustar00rootroot000000 000000 use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.018'; my $trial_token = '-TRIAL'; my $encoding = 'UTF-8'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); if ($encoding) { require Encode; $changelog = Encode::decode($encoding, $changelog, Encode::FB_CROAK()); } close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; }