Porting/ - functions for building and installing POD


    require './Porting/';


This program, when required into other programs in the Perl 5 core distribution, provides functions useful during building and, secondarily, testing.

As of this writing, the functions in this program are used in these other programs:


Note: Since these functions are used during the Perl build process, they must work with miniperl. That necessarily implies that these functions must not rely on XS modules, either directly or indirectly (e.g., autodie).



  • Purpose

    Exit from a process with an error code and a message.

  • Arguments

    List of arguments to be passed with the error message. Example:

        close $fh or my_die("close 'utils.lst': $!");
  • Return Value

    Exit code 255.

  • Comment

    Prints ABORTED to STDERR.


  • Purpose

    Opens a file or fails if it cannot.

  • Arguments

    String holding filename to be opened. Example:

        $fh = open_or_die('utils.lst');
  • Return Value

    Handle to opened file.


  • Purpose

    Read the contents of a file into memory as a single string.

  • Arguments

    String holding name of file to be read into memory.

        $olddelta = slurp_or_die('pod/perldelta.pod');
  • Return Value

    String holding contents of file.


  • Purpose

    Write out a string to a file.

  • Arguments

    List of two arguments: (i) String holding name of file to be written to; (ii) String holding contents to be written.

        write_or_die($olddeltaname, $olddelta);
  • Return Value

    Implicitly returns true value upon success.


  • Purpose

    Verify that a makefile or makefile constructor contains exactly one contiguous run of lines which matches a given pattern. croak()s if the pattern is not found, or found in more than one place.

    By "makefile or makefile constructor" we mean a file which is one of the right-hand values in this list of key-value pairs:

                manifest => 'MANIFEST',
                vms => 'vms/descrip_mms.template',
                nmake => 'win32/Makefile',
                gmake => 'win32/GNUmakefile',
                podmak => 'win32/pod.mak',
                unix => 'Makefile.SH',

    (Currently found in %Targets in Porting/

  • Arguments

    • Name of target

      String holding the key of one element in %Targets in Porting/

    • Contents of file

      String holding slurped contents of the file named in the value of the element in %Targets in Porting/ named in the first argument.

    • Pattern of interest

      Compiled regular expression pertinent to a particular makefile constructor.

    • Name to report on error

      String holding description.

  • Return Value

    The contents of the file, with qr/\0+/ substituted for the pattern.

  • Example (drawn from Porting/ do_unix()):

        my $makefile_SH = slurp_or_die('./Makefile.SH');
        my $re = qr/some\s+pattern/;
        my $makefile_SH_out =
            verify_contiguous('unix', $makefile_SH, $re, 'copy rules');


  • Purpose

    Read a file from disk, pass the contents to the callback, and either update the file on disk (if changed) or generate TAP output to confirm that the version on disk is up to date. dies if the file contains any NUL bytes. This permits the callback routine to use NUL bytes as placeholders while manipulating the file's contents.

  • Arguments

    • Description for use in error messages

    • Name of file

    • Callback

      Passed description and file contents, should return updated file contents.

    • Test number

      If defined, generate TAP output to STDOUT. If defined and false, generate an unnumbered test. Otherwise this is the test number in the ok line.

    • Verbose flag

      If true, generate verbose output.

  • Return Value

    Does not return anything.


  • Purpose

    Create a lookup table holding information about PODs to be installed.

  • Arguments


  • Return Value

    Reference to a hash with a structure like this:

        $found = {
          'MODULE' => {
            'CPAN::Bundle' => 'lib/CPAN/',
            'Locale::Codes::Script_Retired' =>
            'Pod::Simple::DumpAsText' =>
            # ...
            'Locale::Codes::LangVar' =>
          'PRAGMA' => {
            'fields' => 'lib/',
            'subs' => 'lib/',
            # ...
  • Comment

    Broadly speaking, the function assembles a list of all .pm and .pod files in the distribution and then excludes certain files from installation.


  • Purpose

    Create a data structure holding information about files containing text in POD format.

  • Arguments

    List of one or more arguments.

    • Boolean true or false

    • Reference to a subroutine.

    • Various other arguments.


        $state = get_pod_metadata(
            0, sub { warn @_ if @_ }, 'pod/perltoc.pod');
            1, sub { warn @_ if @_ }, values %Build);
  • Return Value

    Hash reference; each element provides either a list or a lookup table for information about various types of POD files.

      'aux'             => [ # utility programs like
                                'h2xs' and 'perldoc' ]
      'generated'       => { # lookup table for generated POD files
                                like 'perlapi.pod' }
      'ignore'          => { # lookup table for files to be ignored }
      'pods'            => { # lookup table in "name" =>
                                "short description" format }
      'readmes'         => { # lookup table for OS-specific
                                and other READMEs }
      'delta_version'   => [ # major version number, minor no.,
                                patch no. ]
      'delta_target'    => 'perl<Mmmpp>delta.pod',
      'master'          => [ # list holding entries for files callable
                            by 'perldoc' ]
      'copies'          => { # patch version perldelta =>
                            minor version perldelta }
  • Comment

    Instances where this subroutine is used may be found in these files: