{
    "content": [
        {
            "type": "text",
            "text": "# Sub::Defer (perldoc)\n\n## NAME\n\nSub::Defer - Defer generation of subroutines until they are first called\n\n## SYNOPSIS\n\nuse Sub::Defer;\nmy $deferred = defersub 'Logger::timesincefirstlog' => sub {\nmy $t = time;\nsub { time - $t };\n};\nLogger->timesincefirstlog; # returns 0 and replaces itself\nLogger->timesincefirstlog; # returns time - $t\n\n## DESCRIPTION\n\nThese subroutines provide the user with a convenient way to defer creation of subroutines and\nmethods until they are first called.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SUBROUTINES**\n- **SUPPORT**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Sub::Defer",
        "section": "",
        "mode": "perldoc",
        "summary": "Sub::Defer - Defer generation of subroutines until they are first called",
        "synopsis": "use Sub::Defer;\nmy $deferred = defersub 'Logger::timesincefirstlog' => sub {\nmy $t = time;\nsub { time - $t };\n};\nLogger->timesincefirstlog; # returns 0 and replaces itself\nLogger->timesincefirstlog; # returns time - $t",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SUBROUTINES",
                "lines": 64,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Sub::Defer - Defer generation of subroutines until they are first called\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Sub::Defer;\n\nmy $deferred = defersub 'Logger::timesincefirstlog' => sub {\nmy $t = time;\nsub { time - $t };\n};\n\nLogger->timesincefirstlog; # returns 0 and replaces itself\nLogger->timesincefirstlog; # returns time - $t\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "These subroutines provide the user with a convenient way to defer creation of subroutines and\nmethods until they are first called.\n",
                "subsections": []
            },
            "SUBROUTINES": {
                "content": "defersub\nmy $coderef = defersub $name => sub { ... }, \\%options;\n\nThis subroutine returns a coderef that encapsulates the provided sub - when it is first called,\nthe provided sub is called and is -itself- expected to return a subroutine which will be goto'ed\nto on subsequent calls.\n\nIf a name is provided, this also installs the sub as that name - and when the subroutine is\nundeferred will re-install the final version for speed.\n\nExported by default.\n\nOptions\nA hashref of options can optionally be specified.\n\npackage\nThe package to generate the sub in. Will be overridden by a fully qualified $name option. If\nnot specified, will default to the caller's package.\n\nattributes\nThe \"Subroutine Attributes\" in perlsub to apply to the sub generated. Should be specified as\nan array reference.\n\nundefersub\nmy $coderef = undefersub \\&Foo::name;\n\nIf the passed coderef has been deferred this will \"undefer\" it. If the passed coderef has not\nbeen deferred, this will just return it.\n\nIf this is confusing, take a look at the example in the \"SYNOPSIS\".\n\nExported by default.\n\ndeferinfo\nmy $data = deferinfo $sub;\nmy ($name, $generator, $options, $undeferredsub) = @$data;\n\nReturns original arguments to defersub, plus the undeferred version if this sub has already\nbeen undeferred.\n\nNote that $sub can be either the original deferred version or the undeferred version for\nconvenience.\n\nNot exported by default.\n\nundeferall\nundeferall();\n\nThis will undefer all deferred subs in one go. This can be very useful in a forking environment\nwhere child processes would each have to undefer the same subs. By calling this just before you\nstart forking children you can undefer all currently deferred subs in the parent so that the\nchildren do not have to do it. Note this may bake the behavior of some subs that were intended\nto calculate their behavior later, so it shouldn't be used midway through a module load or class\ndefinition.\n\nExported by default.\n\nundeferpackage\nundeferpackage($package);\n\nThis undefers all deferred subs in a package.\n\nNot exported by default.\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "See Sub::Quote for support and contact information.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "See Sub::Quote for authors.\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "See Sub::Quote for the copyright and license.\n",
                "subsections": []
            }
        }
    }
}