{
    "mode": "perldoc",
    "parameter": "ExtUtils::MakeMaker::Tutorial",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/ExtUtils%3A%3AMakeMaker%3A%3ATutorial/json",
    "generated": "2026-06-11T18:21:38Z",
    "synopsis": "use ExtUtils::MakeMaker;\nWriteMakefile(\nNAME            => 'Your::Module',\nVERSIONFROM    => 'lib/Your/Module.pm'\n);",
    "sections": {
        "NAME": {
            "content": "ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use ExtUtils::MakeMaker;\n\nWriteMakefile(\nNAME            => 'Your::Module',\nVERSIONFROM    => 'lib/Your/Module.pm'\n);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a short tutorial on writing a simple module with MakeMaker. It's really not that hard.\n",
            "subsections": [
                {
                    "name": "The Mantra",
                    "content": "MakeMaker modules are installed using this simple mantra\n\nperl Makefile.PL\nmake\nmake test\nmake install\n\nThere are lots more commands and options, but the above will do it.\n"
                },
                {
                    "name": "The Layout",
                    "content": "The basic files in a module look something like this.\n\nMakefile.PL\nMANIFEST\nlib/Your/Module.pm\n\nThat's all that's strictly necessary. There's additional files you might want:\n\nlib/Your/Other/Module.pm\nt/sometest.t\nt/someothertest.t\nChanges\nREADME\nINSTALL\nMANIFEST.SKIP\nbin/someprogram\n\nMakefile.PL\nWhen you run Makefile.PL, it makes a Makefile. That's the whole point of MakeMaker. The\nMakefile.PL is a simple program which loads ExtUtils::MakeMaker and runs the WriteMakefile()\nfunction to generate a Makefile.\n\nHere's an example of what you need for a simple module:\n\nuse ExtUtils::MakeMaker;\n\nWriteMakefile(\nNAME            => 'Your::Module',\nVERSIONFROM    => 'lib/Your/Module.pm'\n);\n\nNAME is the top-level namespace of your module. VERSIONFROM is the file which contains the\n$VERSION variable for the entire distribution. Typically this is the same as your top-level\nmodule.\n\nMANIFEST\nA simple listing of all the files in your distribution.\n\nMakefile.PL\nMANIFEST\nlib/Your/Module.pm\n\nFile paths in a MANIFEST always use Unix conventions (ie. /) even if you're not on Unix.\n\nYou can write this by hand or generate it with 'make manifest'.\n\nSee ExtUtils::Manifest for more details.\n\nlib/\nThis is the directory where the .pm and .pod files you wish to have installed go. They are\nlaid out according to namespace. So Foo::Bar is lib/Foo/Bar.pm.\n\nt/  Tests for your modules go here. Each test filename ends with a .t. So t/foo.t 'make test'\nwill run these tests.\n\nTypically, the t/ test directory is flat, with all test files located directly within it.\nHowever, you can nest tests within subdirectories, for example:\n\nt/foo/subdirtest.t\n\nTo do this, you need to inform \"WriteMakeFile()\" in your *Makefile.PL* file in the following\nfashion:\n\ntest => {TESTS => 't/*.t t/*/*.t'}\n\nThat will run all tests in t/, as well as all tests in all subdirectories that reside under\nt/. You can nest as deeply as makes sense for your project. Simply add another entry in the\ntest location string. For example, to test:\n\nt/foo/bar/subdirtest.t\n\nYou would use the following \"test\" directive:\n\ntest => {TESTS => 't/*.t t/*/*/*.t'}\n\nNote that in the above example, tests in the first subdirectory will not be run. To run all\ntests in the intermediary subdirectory preceding the one the test files are in, you need to\nexplicitly note it:\n\ntest => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'}\n\nYou don't need to specify wildcards if you only want to test within specific subdirectories.\nThe following example will only run tests in t/foo:\n\ntest => {TESTS => 't/foo/*.t'}\n\nTests are run from the top level of your distribution. So inside a test you would refer to\n./lib to enter the lib directory, for example.\n\nChanges\nA log of changes you've made to this module. The layout is free-form. Here's an example:\n\n1.01 Fri Apr 11 00:21:25 PDT 2003\n- thing() does some stuff now\n- fixed the wiggy bug in withit()\n\n1.00 Mon Apr  7 00:57:15 PDT 2003\n- \"Rain of Frogs\" now supported\n\nREADME\nA short description of your module, what it does, why someone would use it and its\nlimitations. CPAN automatically pulls your README file out of the archive and makes it\navailable to CPAN users, it is the first thing they will read to decide if your module is\nright for them.\n\nINSTALL\nInstructions on how to install your module along with any dependencies. Suggested\ninformation to include here:\n\nany extra modules required for use\nthe minimum version of Perl required\nif only works on certain operating systems\n\nMANIFEST.SKIP\nA file full of regular expressions to exclude when using 'make manifest' to generate the\nMANIFEST. These regular expressions are checked against each file path found in the\ndistribution (so you're matching against \"t/foo.t\" not \"foo.t\").\n\nHere's a sample:\n\n~$          # ignore emacs and vim backup files\n.bak$       # ignore manual backups\n\\#          # ignore CVS old revision files and emacs temp files\n\nSince # can be used for comments, # must be escaped.\n\nMakeMaker comes with a default MANIFEST.SKIP to avoid things like version control\ndirectories and backup files. Specifying your own will override this default.\n\nbin/\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "perlmodstyle gives stylistic help writing a module.\n\nperlnewmod gives more information about how to write a module.\n\nThere are modules to help you through the process of writing a module: ExtUtils::ModuleMaker,\nModule::Starter, Minilla::Tutorial, Dist::Milla::Tutorial, Dist::Zilla::Starter\n",
            "subsections": []
        }
    },
    "summary": "ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker",
    "flags": [],
    "examples": [],
    "see_also": []
}