PERLSOURCE(1) Perl Programmers Reference Guide PERLSOURCE(1) #
PERLSOURCE(1) Perl Programmers Reference Guide PERLSOURCE(1)
NNAAMMEE #
perlsource - A guide to the Perl source tree
DDEESSCCRRIIPPTTIIOONN #
This document describes the layout of the Perl source tree. If you're
hacking on the Perl core, this will help you find what you're looking
for.
FFIINNDDIINNGG YYOOUURR WWAAYY AARROOUUNNDD #
The Perl source tree is big. Here's some of the thing you'll find in it:
CC ccooddee The C source code and header files mostly live in the root of the source tree. There are a few platform-specific directories which contain C code. In addition, some of the modules shipped with Perl include C or XS code.
See perlinterp for more details on the files that make up the Perl
interpreter, as well as details on how it works.
CCoorree mmoodduulleess Modules shipped as part of the Perl core live in four subdirectories. Two of these directories contain modules that live in the core, and two contain modules that can also be released separately on CPAN. Modules which can be released on cpan are known as “dual-life” modules.
• _l_i_b_/
This directory contains pure-Perl modules which are only released as
part of the core. This directory contains _a_l_l of the modules and
their tests, unlike other core modules.
• _e_x_t_/
Like _l_i_b_/, this directory contains modules which are only released as
part of the core. Unlike _l_i_b_/, however, a module under _e_x_t_/
generally has a CPAN-style directory- and file-layout and its own
_M_a_k_e_f_i_l_e_._P_L. There is no expectation that a module under _e_x_t_/ will
work with earlier versions of Perl 5. Hence, such a module may take
full advantage of syntactical and other improvements in Perl 5 blead.
• _d_i_s_t_/
This directory is for dual-life modules where the blead source is
canonical. Note that some modules in this directory may not yet have
been released separately on CPAN. Modules under _d_i_s_t_/ should make an
effort to work with earlier versions of Perl 5.
• _c_p_a_n_/
This directory contains dual-life modules where the CPAN module is
canonical. Do not patch these modules directly! Changes to these
modules should be submitted to the maintainer of the CPAN module.
Once those changes are applied and released, the new version of the
module will be incorporated into the core.
For some dual-life modules, it has not yet been determined if the CPAN
version or the blead source is canonical. Until that is done, those
modules should be in _c_p_a_n_/.
TTeessttss The Perl core has an extensive test suite. If you add new tests (or new modules with tests), you may need to update the _t_/_T_E_S_T file so that the tests are run.
• Module tests
Tests for core modules in the _l_i_b_/ directory are right next to the
module itself. For example, we have _l_i_b_/_s_t_r_i_c_t_._p_m and _l_i_b_/_s_t_r_i_c_t_._t.
Tests for modules in _e_x_t_/ and the dual-life modules are in _t_/
subdirectories for each module, like a standard CPAN distribution.
• _t_/_b_a_s_e_/
Tests for the absolute basic functionality of Perl. This includes
"if", basic file reads and writes, simple regexes, etc. These are run
first in the test suite and if any of them fail, something is _r_e_a_l_l_y
broken.
• _t_/_c_m_d_/
Tests for basic control structures, "if"/"else", "while",
subroutines, etc.
• _t_/_c_o_m_p_/
Tests for basic issues of how Perl parses and compiles itself.
• _t_/_i_o_/
Tests for built-in IO functions, including command line arguments.
• _t_/_m_r_o_/
Tests for perl's method resolution order implementations (see mro).
• _t_/_o_p_/
Tests for perl's built in functions that don't fit into any of the
other directories.
• _t_/_o_p_b_a_s_i_c_/
Tests for perl's built in functions which, like those in _t_/_o_p_/, do
not fit into any of the other directories, but which, in addition,
cannot use _t_/_t_e_s_t_._p_l,as that program depends on functionality which
the test file itself is testing.
• _t_/_r_e_/
Tests for regex related functions or behaviour. (These used to live
in t/op).
• _t_/_r_u_n_/
Tests for features of how perl actually runs, including exit codes
and handling of PERL* environment variables.
• _t_/_u_n_i_/
Tests for the core support of Unicode.
• _t_/_w_i_n_3_2_/
Windows-specific tests.
• _t_/_p_o_r_t_i_n_g_/
Tests the state of the source tree for various common errors. For
example, it tests that everyone who is listed in the git log has a
corresponding entry in the _A_U_T_H_O_R_S file.
• _t_/_l_i_b_/
The old home for the module tests, you shouldn't put anything new in
here. There are still some bits and pieces hanging around in here
that need to be moved. Perhaps you could move them? Thanks!
DDooccuummeennttaattiioonn All of the core documentation intended for end users lives in _p_o_d_/. Individual modules in _l_i_b_/, _e_x_t_/, _d_i_s_t_/, and _c_p_a_n_/ usually have their own documentation, either in the _M_o_d_u_l_e_._p_m file or an accompanying _M_o_d_u_l_e_._p_o_d file.
Finally, documentation intended for core Perl developers lives in the
_P_o_r_t_i_n_g_/ directory.
HHaacckkiinngg ttoooollss aanndd ddooccuummeennttaattiioonn The _P_o_r_t_i_n_g directory contains a grab bag of code and documentation intended to help porters work on Perl. Some of the highlights include:
• _c_h_e_c_k_*
These are scripts which will check the source things like ANSI C
violations, POD encoding issues, etc.
• _M_a_i_n_t_a_i_n_e_r_s, _M_a_i_n_t_a_i_n_e_r_s_._p_l, and _M_a_i_n_t_a_i_n_e_r_s_._p_m
These files contain information on who maintains which modules. Run
"perl Porting/Maintainers -M Module::Name" to find out more
information about a dual-life module.
• _p_o_d_t_i_d_y
Tidies a pod file. It's a good idea to run this on a pod file you've
patched.
BBuuiilldd ssyysstteemm The Perl build system on *nix-like systems starts with the _C_o_n_f_i_g_u_r_e script in the root directory.
Platform-specific pieces of the build system also live in platform-
specific directories like _w_i_n_3_2_/, _v_m_s_/, etc. Windows and VMS have their
own Configure-like scripts, in their respective directories.
The _C_o_n_f_i_g_u_r_e script (or a platform-specific similar script) is
ultimately responsible for generating a _M_a_k_e_f_i_l_e from _M_a_k_e_f_i_l_e_._S_H.
The build system that Perl uses is called metaconfig. This system is
maintained separately from the Perl core, and knows about the platform-
specific Configure-like scripts, as well as _C_o_n_f_i_g_u_r_e itself.
The metaconfig system has its own git repository. Please see its README
file in <https://github.com/Perl/metaconfig> for more details.
The _C_r_o_s_s directory contains various files related to cross-compiling
Perl. See _C_r_o_s_s_/_R_E_A_D_M_E for more details.
_A_U_T_H_O_R_S #
This file lists everyone who's contributed to Perl. If you submit a
patch, you should add your name to this file as part of the patch.
_M_A_N_I_F_E_S_T #
The _M_A_N_I_F_E_S_T file in the root of the source tree contains a list of every
file in the Perl core, as well as a brief description of each file.
You can get an overview of all the files with this command:
% perl -lne 'print if /^[^\/]+\.[ch]\s+/' MANIFEST
perl v5.36.3 2021-03-02 PERLSOURCE(1)