{
    "mode": "perldoc",
    "parameter": "Sub::Install",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Sub%3A%3AInstall/json",
    "generated": "2026-06-12T06:20:36Z",
    "synopsis": "use Sub::Install;\nSub::Install::installsub({\ncode => sub { ... },\ninto => $package,\nas   => $subname\n});",
    "sections": {
        "NAME": {
            "content": "Sub::Install - install subroutines into packages easily\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 0.928\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Sub::Install;\n\nSub::Install::installsub({\ncode => sub { ... },\ninto => $package,\nas   => $subname\n});\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module makes it easy to install subroutines into packages without the unsightly mess of \"no\nstrict\" or typeglobs lying about where just anyone can see them.\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "installsub\nSub::Install::installsub({\ncode => \\&subroutine,\ninto => \"Finance::Shady\",\nas   => 'launder',\n});\n\nThis routine installs a given code reference into a package as a normal subroutine. The above is\nequivalent to:\n\nno strict 'refs';\n*{\"Finance::Shady\" . '::' . \"launder\"} = \\&subroutine;\n\nIf \"into\" is not given, the sub is installed into the calling package.\n\nIf \"code\" is not a code reference, it is looked for as an existing sub in the package named in\nthe \"from\" parameter. If \"from\" is not given, it will look in the calling package.\n\nIf \"as\" is not given, and if \"code\" is a name, \"as\" will default to \"code\". If \"as\" is not\ngiven, but if \"code\" is a code ref, Sub::Install will try to find the name of the given code ref\nand use that as \"as\".\n\nThat means that this code:\n\nSub::Install::installsub({\ncode => 'twitch',\nfrom => 'Person::InPain',\ninto => 'Person::Teenager',\nas   => 'dance',\n});\n\nis the same as:\n\npackage Person::Teenager;\n\nSub::Install::installsub({\ncode => Person::InPain->can('twitch'),\nas   => 'dance',\n});\n\nreinstallsub\nThis routine behaves exactly like \"installsub\", but does not emit a warning if warnings are on\nand the destination is already defined.\n\ninstallinstallers\nThis routine is provided to allow Sub::Install compatibility with Sub::Installer. It installs\n\"installsub\" and \"reinstallsub\" methods into the package named by its argument.\n\nSub::Install::installinstallers('Code::Builder'); # just for us, please\nCode::Builder->installsub({ name => $coderef });\n\nSub::Install::installinstallers('UNIVERSAL'); # feeling lucky, punk?\nAnything::At::All->installsub({ name => $coderef });\n\nThe installed installers are similar, but not identical, to those provided by Sub::Installer.\nThey accept a single hash as an argument. The key/value pairs are used as the \"as\" and \"code\"\nparameters to the \"installsub\" routine detailed above. The package name on which the method is\ncalled is used as the \"into\" parameter.\n\nUnlike Sub::Installer's \"installsub\" will not eval strings into code, but will look for named\ncode in the calling package.\n",
            "subsections": []
        },
        "EXPORTS": {
            "content": "Sub::Install exports \"installsub\" and \"reinstallsub\" only if they are requested.\n\nexporter\nSub::Install has a never-exported subroutine called \"exporter\", which is used to implement its\n\"import\" routine. It takes a hashref of named arguments, only one of which is currently\nrecognize: \"exports\". This must be an arrayref of subroutines to offer for export.\n\nThis routine is mainly for Sub::Install's own consumption. Instead, consider Sub::Exporter.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Sub::Installer\nThis module is (obviously) a reaction to Damian Conway's Sub::Installer, which does the same\nthing, but does it by getting its greasy fingers all over UNIVERSAL. I was really happy\nabout the idea of making the installation of coderefs less ugly, but I couldn't bring myself\nto replace the ugliness of typeglobs and loosened strictures with the ugliness of UNIVERSAL\nmethods.\n\nSub::Exporter\nThis is a complete Exporter.pm replacement, built atop Sub::Install.\n",
            "subsections": []
        },
        "EXTRA CREDITS": {
            "content": "Several of the tests are adapted from tests that shipped with Damian Conway's Sub-Installer\ndistribution.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Ricardo SIGNES <rjbs@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2005 by Ricardo SIGNES.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Sub::Install - install subroutines into packages easily",
    "flags": [],
    "examples": [],
    "see_also": []
}