{
    "content": [
        {
            "type": "text",
            "text": "# perlhack (man)\n\n## NAME\n\nperlhack - How to hack on Perl\n\n## DESCRIPTION\n\nThis document explains how Perl development works.  It includes details about the Perl 5\nPorters email list, the Perl repository, the Perl bug tracker, patch guidelines, and\ncommentary on Perl development philosophy.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION**\n- **SUPER QUICK PATCH GUIDE**\n- **BUG REPORTING**\n- **PERL 5 PORTERS** (2 subsections)\n- **GETTING THE PERL SOURCE** (4 subsections)\n- **PATCHING PERL** (5 subsections)\n- **TESTING** (5 subsections)\n- **MORE READING FOR GUTS HACKERS**\n- **CPAN TESTERS AND PERL SMOKERS** (3 subsections)\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "perlhack",
        "section": "",
        "mode": "man",
        "summary": "perlhack - How to hack on Perl",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SUPER QUICK PATCH GUIDE",
                "lines": 99,
                "subsections": []
            },
            {
                "name": "BUG REPORTING",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "PERL 5 PORTERS",
                "lines": 8,
                "subsections": [
                    {
                        "name": "perl-changes mailing list",
                        "lines": 4
                    },
                    {
                        "name": "#p5p on IRC",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "GETTING THE PERL SOURCE",
                "lines": 6,
                "subsections": [
                    {
                        "name": "Read access via Git",
                        "lines": 11
                    },
                    {
                        "name": "Read access via the web",
                        "lines": 4
                    },
                    {
                        "name": "Read access via rsync",
                        "lines": 16
                    },
                    {
                        "name": "Write access via git",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "PATCHING PERL",
                "lines": 4,
                "subsections": [
                    {
                        "name": "Submitting patches",
                        "lines": 17
                    },
                    {
                        "name": "Getting your patch accepted",
                        "lines": 190
                    },
                    {
                        "name": "Patching a core module",
                        "lines": 15
                    },
                    {
                        "name": "Updating perldelta",
                        "lines": 24
                    },
                    {
                        "name": "What makes for a good patch?",
                        "lines": 114
                    }
                ]
            },
            {
                "name": "TESTING",
                "lines": 76,
                "subsections": [
                    {
                        "name": "Special \"make test\" targets",
                        "lines": 45
                    },
                    {
                        "name": "Parallel tests",
                        "lines": 26
                    },
                    {
                        "name": "Running tests by hand",
                        "lines": 91
                    },
                    {
                        "name": "Performance testing",
                        "lines": 16
                    },
                    {
                        "name": "Building perl at older commits",
                        "lines": 45
                    }
                ]
            },
            {
                "name": "MORE READING FOR GUTS HACKERS",
                "lines": 53,
                "subsections": []
            },
            {
                "name": "CPAN TESTERS AND PERL SMOKERS",
                "lines": 12,
                "subsections": [
                    {
                        "name": "WHAT NEXT?",
                        "lines": 18
                    },
                    {
                        "name": "\"The Road goes ever on and on, down from the door where it began.\"",
                        "lines": 3
                    },
                    {
                        "name": "Metaphoric Quotations",
                        "lines": 39
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "perlhack - How to hack on Perl\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This document explains how Perl development works.  It includes details about the Perl 5\nPorters email list, the Perl repository, the Perl bug tracker, patch guidelines, and\ncommentary on Perl development philosophy.\n",
                "subsections": []
            },
            "SUPER QUICK PATCH GUIDE": {
                "content": "If you just want to submit a single small patch like a pod fix, a test for a bug, comment\nfixes, etc., it's easy! Here's how:\n\n•   Check out the source repository\n\nThe perl source is in a git repository.  You can clone the repository with the following\ncommand:\n\n% git clone https://github.com/Perl/perl5.git perl\n\n•   Ensure you're following the latest advice\n\nIn case the advice in this guide has been updated recently, read the latest version\ndirectly from the perl source:\n\n% perldoc pod/perlhack.pod\n\n•   Create a branch for your change\n\nCreate a branch based on blead to commit your change to, which will later be used to send\nit to the Perl issue tracker.\n\n% git checkout -b mychange\n\n•   Make your change\n\nHack, hack, hack.  Keep in mind that Perl runs on many different platforms, with\ndifferent operating systems that have different capabilities, different filesystem\norganizations, and even different character sets.  perlhacktips gives advice on this.\n\n•   Test your change\n\nYou can run all the tests with the following commands:\n\n% ./Configure -des -Dusedevel\n% make test\n\nKeep hacking until the tests pass.\n\n•   Commit your change\n\nCommitting your work will save the change on your local system:\n\n% git commit -a -m 'Commit message goes here'\n\nMake sure the commit message describes your change in a single sentence.  For example,\n\"Fixed spelling errors in perlhack.pod\".\n\n•   Send your change to the Perl issue tracker\n\nThe next step is to submit your patch to the Perl core ticket system.\n\nCreate a GitHub fork of the perl5 repository and add it as a remote, if you haven't\nalready, as described in the GitHub documentation at\n<https://help.github.com/en/articles/working-with-forks>.\n\n% git remote add fork git@github.com:MyUser/perl5.git\n\nFor more information, see \"Connecting to GitHub with SSH\"\n<https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-\ngithub/connecting-to-github-with-ssh>.\n\nIf you'd rather use an HTTPS URL for your \"git push\" see \"Cloning with HTTPS URLs\"\n<https://docs.github.com/en/free-pro-team@latest/github/using-git/which-remote-url-\nshould-i-use#cloning-with-https-urls>.\n\n% git remote add fork https://github.com/MyUser/perl5.git\n\nThen, push your new branch to your fork.\n\n% git push -u fork mychange\n\nFinally, create a Pull Request on GitHub from your branch to blead as described in the\nGitHub documentation at\n<https://help.github.com/en/articles/creating-a-pull-request-from-a-fork>.\n\n•   Thank you\n\nThe porters appreciate the time you spent helping to make Perl better.  Thank you!\n\n•   Acknowledgement\n\nAll contributors are credited (by name and email address) in the AUTHORS file, which is\npart of the perl distribution, as well as the Git commit history.\n\nIf you don’t want to be included in the AUTHORS file, just let us know. Otherwise we will\ntake your submission of a patch as permission to credit you in the AUTHORS file.\n\n•   Next time\n\nThe next time you wish to make a patch, you need to start from the latest perl in a\npristine state.  Check you don't have any local changes or added files in your perl\ncheck-out which you wish to keep, then run these commands:\n\n% git checkout blead\n% git pull\n% git reset --hard origin/blead\n% git clean -dxf\n",
                "subsections": []
            },
            "BUG REPORTING": {
                "content": "If you want to report a bug in Perl, or browse existing Perl bugs and patches, use the GitHub\nissue tracker at <https://github.com/perl/perl5/issues>.\n\nPlease check the archive of the perl5-porters list (see below) and/or the bug tracking system\nbefore submitting a bug report.  Often, you'll find that the bug has been reported already.\n\nYou can log in to the bug tracking system and comment on existing bug reports.  If you have\nadditional information regarding an existing bug, please add it.  This will help the porters\nfix the bug.\n",
                "subsections": []
            },
            "PERL 5 PORTERS": {
                "content": "The perl5-porters (p5p) mailing list is where the Perl standard distribution is maintained\nand developed.  The people who maintain Perl are also referred to as the \"Perl 5 Porters\",\n\"p5p\" or just the \"porters\".\n\nA searchable archive of the list is available at\n<https://markmail.org/search/?q=perl5-porters>.  There is also an archive at\n<https://archive.develooper.com/perl5-porters@perl.org/>.\n",
                "subsections": [
                    {
                        "name": "perl-changes mailing list",
                        "content": "The perl5-changes mailing list receives a copy of each patch that gets submitted to the\nmaintenance and development branches of the perl repository.  See\n<https://lists.perl.org/list/perl5-changes.html> for subscription and archive information.\n"
                    },
                    {
                        "name": "#p5p on IRC",
                        "content": "Many porters are also active on the <irc://irc.perl.org/#p5p> channel.  Feel free to join the\nchannel and ask questions about hacking on the Perl core.\n"
                    }
                ]
            },
            "GETTING THE PERL SOURCE": {
                "content": "All of Perl's source code is kept centrally in a Git repository at github.com.  The\nrepository contains many Perl revisions from Perl 1 onwards and all the revisions from\nPerforce, the previous version control system.\n\nFor much more detail on using git with the Perl repository, please see perlgit.\n",
                "subsections": [
                    {
                        "name": "Read access via Git",
                        "content": "You will need a copy of Git for your computer.  You can fetch a copy of the repository using\nthe git protocol:\n\n% git clone git://github.com/Perl/perl5.git perl\n\nThis clones the repository and makes a local copy in the perl directory.\n\nIf you cannot use the git protocol for firewall reasons, you can also clone via http:\n\n% git clone https://github.com/Perl/perl5.git perl\n"
                    },
                    {
                        "name": "Read access via the web",
                        "content": "You may access the repository over the web.  This allows you to browse the tree, see recent\ncommits, subscribe to repository notifications, search for particular commits and more.  You\nmay access it at <https://github.com/Perl/perl5>.\n"
                    },
                    {
                        "name": "Read access via rsync",
                        "content": "You can also choose to use rsync to get a copy of the current source tree for the bleadperl\nbranch and all maintenance branches:\n\n% rsync -avz rsync://perl5.git.perl.org/perl-current .\n% rsync -avz rsync://perl5.git.perl.org/perl-5.12.x .\n% rsync -avz rsync://perl5.git.perl.org/perl-5.10.x .\n% rsync -avz rsync://perl5.git.perl.org/perl-5.8.x .\n% rsync -avz rsync://perl5.git.perl.org/perl-5.6.x .\n% rsync -avz rsync://perl5.git.perl.org/perl-5.005xx .\n\n(Add the \"--delete\" option to remove leftover files.)\n\nTo get a full list of the available sync points:\n\n% rsync perl5.git.perl.org::\n"
                    },
                    {
                        "name": "Write access via git",
                        "content": "If you have a commit bit, please see perlgit for more details on using git.\n"
                    }
                ]
            },
            "PATCHING PERL": {
                "content": "If you're planning to do more extensive work than a single small fix, we encourage you to\nread the documentation below.  This will help you focus your work and make your patches\neasier to incorporate into the Perl source.\n",
                "subsections": [
                    {
                        "name": "Submitting patches",
                        "content": "If you have a small patch to submit, please submit it via the GitHub Pull Request workflow.\nYou may also send patches to the p5p list.\n\nPatches are reviewed and discussed on GitHub or the p5p list.  Simple, uncontroversial\npatches will usually be applied without any discussion.  When the patch is applied, the\nticket will be updated and you will receive email.\n\nIn other cases, the patch will need more work or discussion.  You are encouraged to\nparticipate in the discussion and advocate for your patch.  Sometimes your patch may get lost\nin the shuffle.  It's appropriate to send a reminder email to p5p if no action has been taken\nin a month.  Please remember that the Perl 5 developers are all volunteers, and be polite.\n\nChanges are always applied directly to the main development branch, called \"blead\".  Some\npatches may be backported to a maintenance branch.  If you think your patch is appropriate\nfor the maintenance branch (see \"MAINTENANCE BRANCHES\" in perlpolicy), please explain why\nwhen you submit it.\n"
                    },
                    {
                        "name": "Getting your patch accepted",
                        "content": "If you are submitting a code patch there are several things that you can do to help the Perl\n5 Porters accept your patch.\n\nPatch style\n\nUsing the GitHub Pull Request workflow, your patch will automatically be available in a\nsuitable format.  If you wish to submit a patch to the p5p list for review, make sure to\ncreate it appropriately.\n\nIf you used git to check out the Perl source, then using \"git format-patch\" will produce a\npatch in a style suitable for Perl.  The \"format-patch\" command produces one patch file for\neach commit you made.  If you prefer to send a single patch for all commits, you can use \"git\ndiff\".\n\n% git checkout blead\n% git pull\n% git diff blead my-branch-name\n\nThis produces a patch based on the difference between blead and your current branch.  It's\nimportant to make sure that blead is up to date before producing the diff, that's why we call\n\"git pull\" first.\n\nWe strongly recommend that you use git if possible.  It will make your life easier, and ours\nas well.\n\nHowever, if you're not using git, you can still produce a suitable patch.  You'll need a\npristine copy of the Perl source to diff against.  The porters prefer unified diffs.  Using\nGNU \"diff\", you can produce a diff like this:\n\n% diff -Npurd perl.pristine perl.mine\n\nMake sure that you \"make realclean\" in your copy of Perl to remove any build artifacts, or\nyou may get a confusing result.\n\nCommit message\n\nAs you craft each patch you intend to submit to the Perl core, it's important to write a good\ncommit message.  This is especially important if your submission will consist of a series of\ncommits.\n\nThe first line of the commit message should be a short description without a period.  It\nshould be no longer than the subject line of an email, 50 characters being a good rule of\nthumb.\n\nA lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will only display the\nfirst line (cut off at 50 characters) when presenting commit summaries.\n\nThe commit message should include a description of the problem that the patch corrects or new\nfunctionality that the patch adds.\n\nAs a general rule of thumb, your commit message should help a programmer who knows the Perl\ncore quickly understand what you were trying to do, how you were trying to do it, and why the\nchange matters to Perl.\n\n•   Why\n\nYour commit message should describe why the change you are making is important.  When\nsomeone looks at your change in six months or six years, your intent should be clear.\n\nIf you're deprecating a feature with the intent of later simplifying another bit of code,\nsay so.  If you're fixing a performance problem or adding a new feature to support some\nother bit of the core, mention that.\n\n•   What\n\nYour commit message should describe what part of the Perl core you're changing and what\nyou expect your patch to do.\n\n•   How\n\nWhile it's not necessary for documentation changes, new tests or trivial patches, it's\noften worth explaining how your change works.  Even if it's clear to you today, it may\nnot be clear to a porter next month or next year.\n\nA commit message isn't intended to take the place of comments in your code.  Commit messages\nshould describe the change you made, while code comments should describe the current state of\nthe code.\n\nIf you've just implemented a new feature, complete with doc, tests and well-commented code, a\nbrief commit message will often suffice.  If, however, you've just changed a single character\ndeep in the parser or lexer, you might need to write a small novel to ensure that future\nreaders understand what you did and why you did it.\n\nComments, Comments, Comments\n\nBe sure to adequately comment your code.  While commenting every line is unnecessary,\nanything that takes advantage of side effects of operators, that creates changes that will be\nfelt outside of the function being patched, or that others may find confusing should be\ndocumented.  If you are going to err, it is better to err on the side of adding too many\ncomments than too few.\n\nThe best comments explain why the code does what it does, not what it does.\n\nStyle\n\nIn general, please follow the particular style of the code you are patching.\n\nIn particular, follow these general guidelines for patching Perl sources:\n\n•   4-wide indents for code, 2-wide indents for nested CPP \"#define\"s, with 8-wide tabstops.\n\n•   Use spaces for indentation, not tab characters.\n\nThe codebase is a mixture of tabs and spaces for indentation, and we are moving to spaces\nonly.  Converting lines you're patching from 8-wide tabs to spaces will help this\nmigration.\n\n•   Try hard not to exceed 79-columns\n\n•   ANSI C prototypes\n\n•   Uncuddled elses and \"K&R\" style for indenting control constructs\n\n•   No C++ style (//) comments\n\n•   Mark places that need to be revisited with XXX (and revisit often!)\n\n•   Opening brace lines up with \"if\" when conditional spans multiple lines; should be at end-\nof-line otherwise\n\n•   In function definitions, name starts in column 0 (return value-type is on previous line)\n\n•   Single space after keywords that are followed by parens, no space between function name\nand following paren\n\n•   Avoid assignments in conditionals, but if they're unavoidable, use extra paren, e.g. \"if\n(a && (b = c)) ...\"\n\n•   \"return foo;\" rather than \"return(foo);\"\n\n•   \"if (!foo) ...\" rather than \"if (foo == FALSE) ...\" etc.\n\n•   Do not declare variables using \"register\".  It may be counterproductive with modern\ncompilers, and is deprecated in C++, under which the Perl source is regularly compiled.\n\n•   In-line functions that are in headers that are accessible to XS code need to be able to\ncompile without warnings with commonly used extra compilation flags, such as gcc's\n\"-Wswitch-default\" which warns whenever a switch statement does not have a \"default\"\ncase.  The use of these extra flags is to catch potential problems in legal C code, and\nis often used by Perl aggregators, such as Linux distributors.\n\nTest suite\n\nIf your patch changes code (rather than just changing documentation), you should also include\none or more test cases which illustrate the bug you're fixing or validate the new\nfunctionality you're adding.  In general, you should update an existing test file rather than\ncreate a new one.\n\nYour test suite additions should generally follow these guidelines (courtesy of Gurusamy\nSarathy <gsar@activestate.com>):\n\n•   Know what you're testing.  Read the docs, and the source.\n\n•   Tend to fail, not succeed.\n\n•   Interpret results strictly.\n\n•   Use unrelated features (this will flush out bizarre interactions).\n\n•   Use non-standard idioms (otherwise you are not testing TIMTOWTDI).\n\n•   Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT found in\nt/op/tie.t is much more maintainable, and gives better failure reports).\n\n•   Give meaningful error messages when a test fails.\n\n•   Avoid using qx// and system() unless you are testing for them.  If you do use them, make\nsure that you cover all perl platforms.\n\n•   Unlink any temporary files you create.\n\n•   Promote unforeseen warnings to errors with $SIG{WARN}.\n\n•   Be sure to use the libraries and modules shipped with the version being tested, not those\nthat were already installed.\n\n•   Add comments to the code explaining what you are testing for.\n\n•   Make updating the '1..42' string unnecessary.  Or make sure that you update it.\n\n•   Test all behaviors of a given operator, library, or function.\n\nTest all optional arguments.\n\nTest return values in various contexts (boolean, scalar, list, lvalue).\n\nUse both global and lexical variables.\n\nDon't forget the exceptional, pathological cases.\n"
                    },
                    {
                        "name": "Patching a core module",
                        "content": "This works just like patching anything else, with one extra consideration.\n\nModules in the cpan/ directory of the source tree are maintained outside of the Perl core.\nWhen the author updates the module, the updates are simply copied into the core.  See that\nmodule's documentation or its listing on <https://metacpan.org/> for more information on\nreporting bugs and submitting patches.\n\nIn most cases, patches to modules in cpan/ should be sent upstream and should not be applied\nto the Perl core individually.  If a patch to a file in cpan/ absolutely cannot wait for the\nfix to be made upstream, released to CPAN and copied to blead, you must add (or update) a\n\"CUSTOMIZED\" entry in the \"Porting/Maintainers.pl\" file to flag that a local modification has\nbeen made.  See \"Porting/Maintainers.pl\" for more details.\n\nIn contrast, modules in the dist/ directory are maintained in the core.\n"
                    },
                    {
                        "name": "Updating perldelta",
                        "content": "For changes significant enough to warrant a pod/perldelta.pod entry, the porters will greatly\nappreciate it if you submit a delta entry along with your actual change.  Significant changes\ninclude, but are not limited to:\n\n•   Adding, deprecating, or removing core features\n\n•   Adding, deprecating, removing, or upgrading core or dual-life modules\n\n•   Adding new core tests\n\n•   Fixing security issues and user-visible bugs in the core\n\n•   Changes that might break existing code, either on the perl or C level\n\n•   Significant performance improvements\n\n•   Adding, removing, or significantly changing documentation in the pod/ directory\n\n•   Important platform-specific changes\n\nPlease make sure you add the perldelta entry to the right section within pod/perldelta.pod.\nMore information on how to write good perldelta entries is available in the \"Style\" section\nof Porting/howtowriteaperldelta.pod.\n"
                    },
                    {
                        "name": "What makes for a good patch?",
                        "content": "New features and extensions to the language can be contentious.  There is no specific set of\ncriteria which determine what features get added, but here are some questions to consider\nwhen developing a patch:\n\nDoes the concept match the general goals of Perl?\n\nOur goals include, but are not limited to:\n\n1.  Keep it fast, simple, and useful.\n\n2.  Keep features/concepts as orthogonal as possible.\n\n3.  No arbitrary limits (platforms, data sizes, cultures).\n\n4.  Keep it open and exciting to use/patch/advocate Perl everywhere.\n\n5.  Either assimilate new technologies, or build bridges to them.\n\nWhere is the implementation?\n\nAll the talk in the world is useless without an implementation.  In almost every case, the\nperson or people who argue for a new feature will be expected to be the ones who implement\nit.  Porters capable of coding new features have their own agendas, and are not available to\nimplement your (possibly good) idea.\n\nBackwards compatibility\n\nIt's a cardinal sin to break existing Perl programs.  New warnings can be contentious--some\nsay that a program that emits warnings is not broken, while others say it is.  Adding\nkeywords has the potential to break programs, changing the meaning of existing token\nsequences or functions might break programs.\n\nThe Perl 5 core includes mechanisms to help porters make backwards incompatible changes more\ncompatible such as the feature and deprecate modules.  Please use them when appropriate.\n\nCould it be a module instead?\n\nPerl 5 has extension mechanisms, modules and XS, specifically to avoid the need to keep\nchanging the Perl interpreter.  You can write modules that export functions, you can give\nthose functions prototypes so they can be called like built-in functions, you can even write\nXS code to mess with the runtime data structures of the Perl interpreter if you want to\nimplement really complicated things.\n\nWhenever possible, new features should be prototyped in a CPAN module before they will be\nconsidered for the core.\n\nIs the feature generic enough?\n\nIs this something that only the submitter wants added to the language, or is it broadly\nuseful?  Sometimes, instead of adding a feature with a tight focus, the porters might decide\nto wait until someone implements the more generalized feature.\n\nDoes it potentially introduce new bugs?\n\nRadical rewrites of large chunks of the Perl interpreter have the potential to introduce new\nbugs.\n\nHow big is it?\n\nThe smaller and more localized the change, the better.  Similarly, a series of small patches\nis greatly preferred over a single large patch.\n\nDoes it preclude other desirable features?\n\nA patch is likely to be rejected if it closes off future avenues of development.  For\ninstance, a patch that placed a true and final interpretation on prototypes is likely to be\nrejected because there are still options for the future of prototypes that haven't been\naddressed.\n\nIs the implementation robust?\n\nGood patches (tight code, complete, correct) stand more chance of going in.  Sloppy or\nincorrect patches might be placed on the back burner until fixes can be made, or they might\nbe discarded altogether without further notice.\n\nIs the implementation generic enough to be portable?\n\nThe worst patches make use of system-specific features.  It's highly unlikely that non-\nportable additions to the Perl language will be accepted.\n\nIs the implementation tested?\n\nPatches which change behaviour (fixing bugs or introducing new features) must include\nregression tests to verify that everything works as expected.\n\nWithout tests provided by the original author, how can anyone else changing perl in the\nfuture be sure that they haven't unwittingly broken the behaviour the patch implements? And\nwithout tests, how can the patch's author be confident that his/her hard work put into the\npatch won't be accidentally thrown away by someone in the future?\n\nIs there enough documentation?\n\nPatches without documentation are probably ill-thought out or incomplete.  No features can be\nadded or changed without documentation, so submitting a patch for the appropriate pod docs as\nwell as the source code is important.\n\nIs there another way to do it?\n\nLarry said \"Although the Perl Slogan is There's More Than One Way to Do It, I hesitate to\nmake 10 ways to do something\".  This is a tricky heuristic to navigate, though--one man's\nessential addition is another man's pointless cruft.\n\nDoes it create too much work?\n\nWork for the committers, work for Perl programmers, work for module authors, ... Perl is\nsupposed to be easy.\n\nPatches speak louder than words\n\nWorking code is always preferred to pie-in-the-sky ideas.  A patch to add a feature stands a\nmuch higher chance of making it to the language than does a random feature request, no matter\nhow fervently argued the request might be.  This ties into \"Will it be useful?\", as the fact\nthat someone took the time to make the patch demonstrates a strong desire for the feature.\n"
                    }
                ]
            },
            "TESTING": {
                "content": "The core uses the same testing style as the rest of Perl, a simple \"ok/not ok\" run through\nTest::Harness, but there are a few special considerations.\n\nThere are three ways to write a test in the core: Test::More, t/test.pl and ad hoc \"print\n$test ? \"ok 42\\n\" : \"not ok 42\\n\"\".  The decision of which to use depends on what part of the\ntest suite you're working on.  This is a measure to prevent a high-level failure (such as\nConfig.pm breaking) from causing basic functionality tests to fail.\n\nThe t/test.pl library provides some of the features of Test::More, but avoids loading most\nmodules and uses as few core features as possible.\n\nIf you write your own test, use the Test Anything Protocol <https://testanything.org>.\n\n•   t/base, t/comp and t/opbasic\n\nSince we don't know if \"require\" works, or even subroutines, use ad hoc tests for these\nthree.  Step carefully to avoid using the feature being tested.  Tests in t/opbasic, for\ninstance, have been placed there rather than in t/op because they test functionality\nwhich t/test.pl presumes has already been demonstrated to work.\n\n•   All other subdirectories of t/\n\nNow that basic require() and subroutines are tested, you can use the t/test.pl library.\n\nYou can also use certain libraries like Config conditionally, but be sure to skip the\ntest gracefully if it's not there.\n\n•   Test files not found under t/\n\nThis category includes .t files underneath directories such as dist, ext and lib.  Since\nthe core of Perl has now been tested, Test::More can and now should be used.  You can\nalso use the full suite of core modules in the tests.  (As noted in \"Patching a core\nmodule\" above, changes to .t files found under cpan/ should be submitted to the upstream\nmaintainers of those modules.)\n\nWhen you say \"make test\", Perl uses the t/TEST program to run the test suite (except under\nWin32 where it uses t/harness instead).  All tests are run from the t/ directory, not the\ndirectory which contains the test.  This causes some problems with the tests in lib/, so\nhere's some opportunity for some patching.\n\nYou must be triply conscious of cross-platform concerns.  This usually boils down to using\nFile::Spec, avoiding things like \"fork()\" and \"system()\" unless absolutely necessary, and not\nassuming that a given character has a particular ordinal value (code point) or that its UTF-8\nrepresentation is composed of particular bytes.\n\nThere are several functions available to specify characters and code points portably in\ntests.  The always-preloaded functions \"utf8::unicodetonative()\" and its inverse\n\"utf8::nativetounicode()\" take code points and translate appropriately.  The file\nt/charsettools.pl has several functions that can be useful.  It has versions of the previous\ntwo functions that take strings as inputs -- not single numeric code points:\n\"unitonative()\" and \"nativetouni()\".  If you must look at the individual bytes comprising\na UTF-8 encoded string, \"byteutf8atoutf8n()\" takes as input a string of those bytes\nencoded for an ASCII platform, and returns the equivalent string in the native platform.  For\nexample, \"byteutf8atoutf8n(\"\\xC2\\xA0\")\" returns the byte sequence on the current platform\nthat form the UTF-8 for \"U+00A0\", since \"\\xC2\\xA0\" are the UTF-8 bytes on an ASCII platform\nfor that code point.  This function returns \"\\xC2\\xA0\" on an ASCII platform, and \"\\x80\\x41\"\non an EBCDIC 1047 one.\n\nBut easiest is, if the character is specifiable as a literal, like \"A\" or \"%\", to use that;\nif not so specificable, you can use \"\\N{}\" , if the side effects aren't troublesome.  Simply\nspecify all your characters in hex, using \"\\N{U+ZZ}\" instead of \"\\xZZ\".  \"\\N{}\" is the\nUnicode name, and so it always gives you the Unicode character.  \"\\N{U+41}\" is the character\nwhose Unicode code point is 0x41, hence is 'A' on all platforms.  The side effects are:\n\n•   These select Unicode rules.  That means that in double-quotish strings, the string is\nalways converted to UTF-8 to force a Unicode interpretation (you can \"utf8::downgrade()\"\nafterwards to convert back to non-UTF8, if possible).  In regular expression patterns,\nthe conversion isn't done, but if the character set modifier would otherwise be \"/d\", it\nis changed to \"/u\".\n\n•   If you use the form \"\\N{character name}\", the charnames module gets automatically loaded.\nThis may not be suitable for the test level you are doing.\n\nIf you are testing locales (see perllocale), there are helper functions in t/loctools.pl to\nenable you to see what locales there are on the current platform.\n",
                "subsections": [
                    {
                        "name": "Special \"make test\" targets",
                        "content": "There are various special make targets that can be used to test Perl slightly differently\nthan the standard \"test\" target.  Not all them are expected to give a 100% success rate.\nMany of them have several aliases, and many of them are not available on certain operating\nsystems.\n\n•   testporting\n\nThis runs some basic sanity tests on the source tree and helps catch basic errors before\nyou submit a patch.\n\n•   minitest\n\nRun miniperl on t/base, t/comp, t/cmd, t/run, t/io, t/op, t/uni and t/mro tests.\n\nminiperl is a minimalistic perl built to bootstrap building extensions, utilties,\ndocumentation etc.  It doesn't support dynamic loading and depending on the point in the\nbuild process will only have access to a limited set of core modules.  miniperl is not\nintended for day to day use.\n\n•   test.valgrind check.valgrind\n\n(Only in Linux) Run all the tests using the memory leak + naughty memory access tool\n\"valgrind\".  The log files will be named testname.valgrind.\n\n•   testharness\n\nRun the test suite with the t/harness controlling program, instead of t/TEST.  t/harness\nis more sophisticated, and uses the Test::Harness module, thus using this test target\nsupposes that perl mostly works.  The main advantage for our purposes is that it prints a\ndetailed summary of failed tests at the end.  Also, unlike t/TEST, it doesn't redirect\nstderr to stdout.\n\nNote that under Win32 t/harness is always used instead of t/TEST, so there is no special\n\"testharness\" target.\n\nUnder Win32's \"test\" target you may use the TESTSWITCHES and TESTFILES environment\nvariables to control the behaviour of t/harness.  This means you can say\n\nnmake test TESTFILES=\"op/*.t\"\nnmake test TESTSWITCHES=\"-torture\" TESTFILES=\"op/*.t\"\n\n•   test-notty testnotty\n\nSets PERLSKIPTTYTEST to true before running normal test.\n"
                    },
                    {
                        "name": "Parallel tests",
                        "content": "The core distribution can now run its regression tests in parallel on Unix-like and Windows\nplatforms.  On Unix, instead of running \"make test\", set \"TESTJOBS\" in your environment to\nthe number of tests to run in parallel, and run \"make testharness\".  On a Bourne-like shell,\nthis can be done as\n\nTESTJOBS=3 make testharness  # Run 3 tests in parallel\n\nAn environment variable is used, rather than parallel make itself, because TAP::Harness needs\nto be able to schedule individual non-conflicting test scripts itself, and there is no\nstandard interface to \"make\" utilities to interact with their job schedulers.\n\nTests are normally run in a logical order, with the sanity tests first, then the main tests\nof the Perl core functionality, then the tests for the non-core modules.  On many-core\nsystems, this may not use the hardware as effectively as possible.  By also specifying\n\nTESTJOBS=19 PERLTESTHARNESSASAP=1 make -j19 testharness\n\nyou signal that you want the tests to finish in wall-clock time as short as possible.  After\nthe sanity tests are completed, this causes the remaining ones to be packed into the\navailable cores as tightly as we know how.  This has its greatest effect on slower, many-core\nsystems.  Throughput was sped up by 20% on an outmoded 24-core system; less on more recent\nfaster ones with fewer cores.\n\nNote that the command line above added a \"-j\" parameter to make, so as to cause parallel\ncompilation.  This may or may not work on your platform.\n"
                    },
                    {
                        "name": "Running tests by hand",
                        "content": "You can run part of the test suite by hand by using one of the following commands from the t/\ndirectory:\n\n./perl -I../lib TEST list-of-.t-files\n\nor\n\n./perl -I../lib harness list-of-.t-files\n\n(If you don't specify test scripts, the whole test suite will be run.)\n\nUsing t/harness for testing\nIf you use \"harness\" for testing, you have several command line options available to you.\nThe arguments are as follows, and are in the order that they must appear if used together.\n\nharness -v -torture -re=pattern LIST OF FILES TO TEST\nharness -v -torture -re LIST OF PATTERNS TO MATCH\n\nIf \"LIST OF FILES TO TEST\" is omitted, the file list is obtained from the manifest.  The file\nlist may include shell wildcards which will be expanded out.\n\n•   -v\n\nRun the tests under verbose mode so you can see what tests were run, and debug output.\n\n•   -torture\n\nRun the torture tests as well as the normal set.\n\n•   -re=PATTERN\n\nFilter the file list so that all the test files run match PATTERN.  Note that this form\nis distinct from the -re LIST OF PATTERNS form below in that it allows the file list to\nbe provided as well.\n\n•   -re LIST OF PATTERNS\n\nFilter the file list so that all the test files run match /(LIST|OF|PATTERNS)/.  Note\nthat with this form the patterns are joined by '|' and you cannot supply a list of files,\ninstead the test files are obtained from the MANIFEST.\n\nYou can run an individual test by a command similar to\n\n./perl -I../lib path/to/foo.t\n\nexcept that the harnesses set up some environment variables that may affect the execution of\nthe test:\n\n•   PERLCORE=1\n\nindicates that we're running this test as part of the perl core test suite.  This is\nuseful for modules that have a dual life on CPAN.\n\n•   PERLDESTRUCTLEVEL=2\n\nis set to 2 if it isn't set already (see \"PERLDESTRUCTLEVEL\" in perlhacktips).\n\n•   PERL\n\n(used only by t/TEST) if set, overrides the path to the perl executable that should be\nused to run the tests (the default being ./perl).\n\n•   PERLSKIPTTYTEST\n\nif set, tells to skip the tests that need a terminal.  It's actually set automatically by\nthe Makefile, but can also be forced artificially by running 'make testnotty'.\n\nOther environment variables that may influence tests\n\n•   PERLTESTNetPing\n\nSetting this variable runs all the Net::Ping modules tests, otherwise some tests that\ninteract with the outside world are skipped.  See perl58delta.\n\n•   PERLTESTNOVREXX\n\nSetting this variable skips the vrexx.t tests for OS2::REXX.\n\n•   PERLTESTNUMCONVERTS\n\nThis sets a variable in op/numconvert.t.\n\n•   PERLTESTMEMORY\n\nSetting this variable includes the tests in t/bigmem/.  This should be set to the number\nof gigabytes of memory available for testing, eg.  \"PERLTESTMEMORY=4\" indicates that\ntests that require 4GiB of available memory can be run safely.\n\nSee also the documentation for the Test and Test::Harness modules, for more environment\nvariables that affect testing.\n"
                    },
                    {
                        "name": "Performance testing",
                        "content": "The file t/perf/benchmarks contains snippets of perl code which are intended to be\nbenchmarked across a range of perls by the Porting/bench.pl tool. If you fix or enhance a\nperformance issue, you may want to add a representative code sample to the file, then run\nbench.pl against the previous and current perls to see what difference it has made, and\nwhether anything else has slowed down as a consequence.\n\nThe file t/perf/opcount.t is designed to test whether a particular code snippet has been\ncompiled into an optree containing specified numbers of particular op types. This is good for\ntesting whether optimisations which alter ops, such as converting an \"aelem\" op into an\n\"aelemfast\" op, are really doing that.\n\nThe files t/perf/speed.t and t/re/speed.t are designed to test things that run thousands of\ntimes slower if a particular optimisation is broken (for example, the utf8 length cache on\nlong utf8 strings).  Add a test that will take a fraction of a second normally, and minutes\notherwise, causing the test file to time out on failure.\n"
                    },
                    {
                        "name": "Building perl at older commits",
                        "content": "In the course of hacking on the Perl core distribution, you may have occasion to configure,\nbuild and test perl at an old commit.  Sometimes \"make\" will fail during this process.  If\nthat happens, you may be able to salvage the situation by using the Devel::PatchPerl library\nfrom CPAN (not included in the core) to bring the source code at that commit to a buildable\nstate.\n\nHere's a real world example, taken from work done to resolve perl #10118\n<https://github.com/Perl/perl5/issues/10118>.  Use of Porting/bisect.pl had identified commit\n\"ba77e4cc9d1ceebf472c9c5c18b2377ee47062e6\" as the commit in which a bug was corrected.  To\nconfirm, a P5P developer wanted to configure and build perl at commit \"ba77e4c^\" (presumably\n\"bad\") and then at \"ba77e4c\" (presumably \"good\").  Normal configuration and build was\nattempted:\n\n$ sh ./Configure -des -Dusedevel\n$ make testprep\n\n\"make\", however, failed with output (excerpted) like this:\n\ncc -fstack-protector -L/usr/local/lib -o miniperl \\\ngv.o toke.o perly.o pad.o regcomp.o dump.o util.o \\\nmg.o reentr.o mro.o hv.o av.o run.o pphot.o sv.o \\\npp.o scope.o ppctl.o ppsys.o doop.o doio.o regexec.o \\\nutf8.o taint.o deb.o universal.o globals.o perlio.o \\\nnumeric.o mathoms.o locale.o pppack.o ppsort.o  \\\nminiperlmain.o opmini.o perlmini.o\npp.o: In function `Perlpppow':\npp.c:(.text+0x2db9): undefined reference to `pow'\n...\ncollect2: error: ld returned 1 exit status\nmakefile:348: recipe for target 'miniperl' failed\nmake: * [miniperl] Error 1\n\nAnother P5P contributor recommended installation and use of Devel::PatchPerl for this\nsituation, first to determine the version of perl at the commit in question, then to patch\nthe source code at that point to facilitate a build.\n\n$ perl -MDevel::PatchPerl -e \\\n'print Devel::PatchPerl->determineversion(\"/path/to/sourcecode\"), \"\\n\";'\n5.11.1\n$ perl -MDevel::PatchPerl -e \\\n'Devel::PatchPerl->patchsource(\"5.11.1\", \"/path/to/sourcecode\");'\n\nOnce the source was patched, \"./Configure\" and \"make testprep\" were called and completed\nsuccessfully, enabling confirmation of the findings in RT #72414.\n"
                    }
                ]
            },
            "MORE READING FOR GUTS HACKERS": {
                "content": "To hack on the Perl guts, you'll need to read the following things:\n\n•   perlsource\n\nAn overview of the Perl source tree.  This will help you find the files you're looking\nfor.\n\n•   perlinterp\n\nAn overview of the Perl interpreter source code and some details on how Perl does what it\ndoes.\n\n•   perlhacktut\n\nThis document walks through the creation of a small patch to Perl's C code.  If you're\njust getting started with Perl core hacking, this will help you understand how it works.\n\n•   perlhacktips\n\nMore details on hacking the Perl core.  This document focuses on lower level details such\nas how to write tests, compilation issues, portability, debugging, etc.\n\nIf you plan on doing serious C hacking, make sure to read this.\n\n•   perlguts\n\nThis is of paramount importance, since it's the documentation of what goes where in the\nPerl source.  Read it over a couple of times and it might start to make sense - don't\nworry if it doesn't yet, because the best way to study it is to read it in conjunction\nwith poking at Perl source, and we'll do that later on.\n\nGisle Aas's \"illustrated perlguts\", also known as illguts, has very helpful pictures:\n\n<https://metacpan.org/release/RURBAN/illguts-0.49>\n\n•   perlxstut and perlxs\n\nA working knowledge of XSUB programming is incredibly useful for core hacking; XSUBs use\ntechniques drawn from the PP code, the portion of the guts that actually executes a Perl\nprogram.  It's a lot gentler to learn those techniques from simple examples and\nexplanation than from the core itself.\n\n•   perlapi\n\nThe documentation for the Perl API explains what some of the internal functions do, as\nwell as the many macros used in the source.\n\n•   Porting/pumpkin.pod\n\nThis is a collection of words of wisdom for a Perl porter; some of it is only useful to\nthe pumpkin holders, but most of it applies to anyone wanting to go about Perl\ndevelopment.\n",
                "subsections": []
            },
            "CPAN TESTERS AND PERL SMOKERS": {
                "content": "The CPAN testers ( <http://cpantesters.org/> ) are a group of volunteers who test CPAN\nmodules on a variety of platforms.\n\nPerl Smokers ( <https://www.nntp.perl.org/group/perl.daily-build/> and\n<https://www.nntp.perl.org/group/perl.daily-build.reports/> ) automatically test Perl source\nreleases on platforms with various configurations.\n\nBoth efforts welcome volunteers.  In order to get involved in smoke testing of the perl\nitself visit <https://metacpan.org/release/Test-Smoke>.  In order to start smoke testing CPAN\nmodules visit <https://metacpan.org/release/CPANPLUS-YACSmoke> or\n<https://metacpan.org/release/minismokebox> or <https://metacpan.org/release/CPAN-Reporter>.\n",
                "subsections": [
                    {
                        "name": "WHAT NEXT?",
                        "content": "If you've read all the documentation in the document and the ones listed above, you're more\nthan ready to hack on Perl.\n\nHere's some more recommendations\n\n•   Subscribe to perl5-porters, follow the patches and try and understand them; don't be\nafraid to ask if there's a portion you're not clear on - who knows, you may unearth a bug\nin the patch...\n\n•   Do read the README associated with your operating system, e.g.  README.aix on the IBM AIX\nOS.  Don't hesitate to supply patches to that README if you find anything missing or\nchanged over a new OS release.\n\n•   Find an area of Perl that seems interesting to you, and see if you can work out how it\nworks.  Scan through the source, and step over it in the debugger.  Play, poke,\ninvestigate, fiddle! You'll probably get to understand not just your chosen area but a\nmuch wider range of perl's activity as well, and probably sooner than you'd think.\n"
                    },
                    {
                        "name": "\"The Road goes ever on and on, down from the door where it began.\"",
                        "content": "If you can do these things, you've started on the long road to Perl porting.  Thanks for\nwanting to help make Perl better - and happy hacking!\n"
                    },
                    {
                        "name": "Metaphoric Quotations",
                        "content": "If you recognized the quote about the Road above, you're in luck.\n\nMost software projects begin each file with a literal description of each file's purpose.\nPerl instead begins each with a literary allusion to that file's purpose.\n\nLike chapters in many books, all top-level Perl source files (along with a few others here\nand there) begin with an epigrammatic inscription that alludes, indirectly and\nmetaphorically, to the material you're about to read.\n\nQuotations are taken from writings of J.R.R. Tolkien pertaining to his Legendarium, almost\nalways from The Lord of the Rings.  Chapters and page numbers are given using the following\neditions:\n\n•   The Hobbit, by J.R.R. Tolkien.  The hardcover, 70th-anniversary edition of 2007 was used,\npublished in the UK by Harper Collins Publishers and in the US by the Houghton Mifflin\nCompany.\n\n•   The Lord of the Rings, by J.R.R. Tolkien.  The hardcover, 50th-anniversary edition of\n2004 was used, published in the UK by Harper Collins Publishers and in the US by the\nHoughton Mifflin Company.\n\n•   The Lays of Beleriand, by J.R.R. Tolkien and published posthumously by his son and\nliterary executor, C.J.R. Tolkien, being the 3rd of the 12 volumes in Christopher's\nmammoth History of Middle Earth.  Page numbers derive from the hardcover edition, first\npublished in 1983 by George Allen & Unwin; no page numbers changed for the special\n3-volume omnibus edition of 2002 or the various trade-paper editions, all again now by\nHarper Collins or Houghton Mifflin.\n\nOther JRRT books fair game for quotes would thus include The Adventures of Tom Bombadil, The\nSilmarillion, Unfinished Tales, and The Tale of the Children of Hurin, all but the first\nposthumously assembled by CJRT.  But The Lord of the Rings itself is perfectly fine and\nprobably best to quote from, provided you can find a suitable quote there.\n\nSo if you were to supply a new, complete, top-level source file to add to Perl, you should\nconform to this peculiar practice by yourself selecting an appropriate quotation from\nTolkien, retaining the original spelling and punctuation and using the same format the rest\nof the quotes are in.  Indirect and oblique is just fine; remember, it's a metaphor, so being\nmeta is, after all, what it's for.\n"
                    }
                ]
            },
            "AUTHOR": {
                "content": "This document was originally written by Nathan Torkington, and is maintained by the\nperl5-porters mailing list.\n\n\n\nperl v5.34.0                                 2025-07-25                                  PERLHACK(1)",
                "subsections": []
            }
        }
    }
}