{
    "mode": "perldoc",
    "parameter": "strictures",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/strictures/json",
    "generated": "2026-06-11T00:16:51Z",
    "synopsis": "use strictures 2;\nis equivalent to\nuse strict;\nuse warnings FATAL => 'all';\nuse warnings NONFATAL => qw(\nexec\nrecursion\ninternal\nmalloc\nnewline\nexperimental\ndeprecated\nportable\n);\nno warnings 'once';\nexcept when called from a file which matches:\n(caller)[1] =~ /^(?:t|xt|lib|blib)[\\\\\\/]/\nand when either \".git\", \".svn\", \".hg\", or \".bzr\" is present in the current directory (with the\nintention of only forcing extra tests on the author side) -- or when \".git\", \".svn\", \".hg\", or\n\".bzr\" is present two directories up along with \"dist.ini\" (which would indicate we are in a\n\"dzil test\" operation, via Dist::Zilla) -- or when the \"PERLSTRICTURESEXTRA\" environment\nvariable is set, in which case it also does the equivalent of\nno indirect 'fatal';\nno multidimensional;\nno bareword::filehandles;\nNote that \"PERLSTRICTURESEXTRA\" may at some point add even more tests, with only a minor\nversion increase, but any changes to the effect of \"use strictures\" in normal mode will involve\na major version bump.\nIf any of the extra testing modules are not present, strictures will complain loudly, once, via\n\"warn()\", and then shut up. But you really should consider installing them, they're all great\nanti-footgun tools.",
    "sections": {
        "NAME": {
            "content": "strictures - Turn on strict and make most warnings fatal\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use strictures 2;\n\nis equivalent to\n\nuse strict;\nuse warnings FATAL => 'all';\nuse warnings NONFATAL => qw(\nexec\nrecursion\ninternal\nmalloc\nnewline\nexperimental\ndeprecated\nportable\n);\nno warnings 'once';\n\nexcept when called from a file which matches:\n\n(caller)[1] =~ /^(?:t|xt|lib|blib)[\\\\\\/]/\n\nand when either \".git\", \".svn\", \".hg\", or \".bzr\" is present in the current directory (with the\nintention of only forcing extra tests on the author side) -- or when \".git\", \".svn\", \".hg\", or\n\".bzr\" is present two directories up along with \"dist.ini\" (which would indicate we are in a\n\"dzil test\" operation, via Dist::Zilla) -- or when the \"PERLSTRICTURESEXTRA\" environment\nvariable is set, in which case it also does the equivalent of\n\nno indirect 'fatal';\nno multidimensional;\nno bareword::filehandles;\n\nNote that \"PERLSTRICTURESEXTRA\" may at some point add even more tests, with only a minor\nversion increase, but any changes to the effect of \"use strictures\" in normal mode will involve\na major version bump.\n\nIf any of the extra testing modules are not present, strictures will complain loudly, once, via\n\"warn()\", and then shut up. But you really should consider installing them, they're all great\nanti-footgun tools.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "I've been writing the equivalent of this module at the top of my code for about a year now. I\nfigured it was time to make it shorter.\n\nThings like the importer in \"use Moose\" don't help me because they turn warnings on but don't\nmake them fatal -- which from my point of view is useless because I want an exception to tell me\nmy code isn't warnings-clean.\n\nAny time I see a warning from my code, that indicates a mistake.\n\nAny time my code encounters a mistake, I want a crash -- not spew to STDERR and then unknown\n(and probably undesired) subsequent behaviour.\n\nI also want to ensure that obvious coding mistakes, like indirect object syntax (and not so\nobvious mistakes that cause things to accidentally compile as such) get caught, but not at the\ncost of an XS dependency and not at the cost of blowing things up on another machine.\n\nTherefore, strictures turns on additional checking, but only when it thinks it's running in a\ntest file in a VCS checkout -- although if this causes undesired behaviour this can be\noverridden by setting the \"PERLSTRICTURESEXTRA\" environment variable.\n\nIf additional useful author side checks come to mind, I'll add them to the\n\"PERLSTRICTURESEXTRA\" code path only -- this will result in a minor version increase (e.g.\n1.000000 to 1.001000 (1.1.0) or similar). Any fixes only to the mechanism of this code will\nresult in a sub-version increase (e.g. 1.000000 to 1.000001 (1.0.1)).\n",
            "subsections": []
        },
        "CATEGORY SELECTIONS": {
            "content": "strictures does not enable fatal warnings for all categories.\n\nexec\nIncludes a warning that can cause your program to continue running unintentionally after an\ninternal fork. Not safe to fatalize.\n\nrecursion\nInfinite recursion will end up overflowing the stack eventually anyway.\n\ninternal\nTriggers deep within perl, in places that are not safe to trap.\n\nmalloc\nTriggers deep within perl, in places that are not safe to trap.\n\nnewline\nIncludes a warning for using stat on a valid but suspect filename, ending in a newline.\n\nexperimental\nExperimental features are used intentionally.\n\ndeprecated\nDeprecations will inherently be added to in the future in unexpected ways, so making them\nfatal won't be reliable.\n\nportable\nDoesn't indicate an actual problem with the program, only that it may not behave properly if\nrun on a different machine.\n\nonce\nCan't be fatalized. Also triggers very inconsistently, so we just disable it.\n",
            "subsections": []
        },
        "VERSIONS": {
            "content": "Depending on the version of strictures requested, different warnings will be enabled. If no\nspecific version is requested, the current version's behavior will be used. Versions can be\nrequested using perl's standard mechanism:\n\nuse strictures 2;\n\nOr, by passing in a \"version\" option:\n\nuse strictures version => 2;\n\nVERSION 2\nEquivalent to:\n\nuse strict;\nuse warnings FATAL => 'all';\nuse warnings NONFATAL => qw(\nexec\nrecursion\ninternal\nmalloc\nnewline\nexperimental\ndeprecated\nportable\n);\nno warnings 'once';\n\n# and if in dev mode:\nno indirect 'fatal';\nno multidimensional;\nno bareword::filehandles;\n\nAdditionally, any warnings created by modules using warnings::register or\n\"warnings::registercategories()\" will not be fatalized.\n\nVERSION 1\nEquivalent to:\n\nuse strict;\nuse warnings FATAL => 'all';\n# and if in dev mode:\nno indirect 'fatal';\nno multidimensional;\nno bareword::filehandles;\n",
            "subsections": []
        },
        "METHODS": {
            "content": "import\nThis method does the setup work described above in \"DESCRIPTION\". Optionally accepts a \"version\"\noption to request a specific version's behavior.\n\nVERSION\nThis method traps the \"strictures->VERSION(1)\" call produced by a use line with a version number\non it and does the version check.\n",
            "subsections": []
        },
        "EXTRA TESTING RATIONALE": {
            "content": "Every so often, somebody complains that they're deploying via \"git pull\" and that they don't\nwant strictures to enable itself in this case -- and that setting \"PERLSTRICTURESEXTRA\" to 0\nisn't acceptable (additional ways to disable extra testing would be welcome but the discussion\nnever seems to get that far).\n\nIn order to allow us to skip a couple of stages and get straight to a productive conversation,\nhere's my current rationale for turning the extra testing on via a heuristic:\n\nThe extra testing is all stuff that only ever blows up at compile time; this is intentional. So\nthe oft-raised concern that it's different code being tested is only sort of the case -- none of\nthe modules involved affect the final optree to my knowledge, so the author gets some additional\ncompile time crashes which he/she then fixes, and the rest of the testing is completely valid\nfor all environments.\n\nThe point of the extra testing -- especially \"no indirect\" -- is to catch mistakes that newbie\nusers won't even realise are mistakes without help. For example,\n\nfoo { ... };\n\nwhere foo is an & prototyped sub that you forgot to import -- this is pernicious to track down\nsince all *seems* fine until it gets called and you get a crash. Worse still, you can fail to\nhave imported it due to a circular require, at which point you have a load order dependent bug\nwhich I've seen before now *only* show up in production due to tiny differences between the\nproduction and the development environment. I wrote\n<http://shadow.cat/blog/matt-s-trout/indirect-but-still-fatal/> to explain this particular\nproblem before strictures itself existed.\n\nAs such, in my experience so far strictures' extra testing has *avoided* production versus\ndevelopment differences, not caused them.\n\nAdditionally, strictures' policy is very much \"try and provide as much protection as possible\nfor newbies -- who won't think about whether there's an option to turn on or not\" -- so having\nonly the environment variable is not sufficient to achieve that (I get to explain that you need\nto add \"use strict\" at least once a week on freenode #perl -- newbies sometimes completely skip\nsteps because they don't understand that that step is important).\n\nI make no claims that the heuristic is perfect -- it's already been evolved significantly over\ntime, especially for 1.004 where we changed things to ensure it only fires on files in your\ncheckout (rather than strictures-using modules you happened to have installed, which was just\nsilly). However, I hope the above clarifies why a heuristic approach is not only necessary but\ndesirable from a point of view of providing new users with as much safety as possible, and will\nallow any future discussion on the subject to focus on \"how do we minimise annoyance to people\ndeploying from checkouts intentionally\".\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "*   indirect\n\n*   multidimensional\n\n*   bareword::filehandles\n",
            "subsections": []
        },
        "COMMUNITY AND SUPPORT": {
            "content": "IRC channel\nirc.perl.org #toolchain\n\n(or bug 'mst' in query on there or freenode)\n",
            "subsections": [
                {
                    "name": "Git repository",
                    "content": "Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is:\n\ngit clone git://git.shadowcat.co.uk/p5sagit/strictures.git\n\nThe web interface to the repository is at:\n\nhttp://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>\n",
            "subsections": []
        },
        "CONTRIBUTORS": {
            "content": "Karen Etheridge (cpan:ETHER) <ether@cpan.org>\n\nMithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@gmail.com>\n\nhaarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2010 the strictures \"AUTHOR\" and \"CONTRIBUTORS\" as listed above.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This library is free software and may be distributed under the same terms as perl itself.\n",
            "subsections": []
        }
    },
    "summary": "strictures - Turn on strict and make most warnings fatal",
    "flags": [],
    "examples": [],
    "see_also": []
}