Edit: /usr/share/perl5/Module/Runtime.pm (17521B)
=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 onwards 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/C