{
    "content": [
        {
            "type": "text",
            "text": "# Package::Stash (perldoc)\n\n## NAME\n\nPackage::Stash - Routines for manipulating stashes\n\n## SYNOPSIS\n\nmy $stash = Package::Stash->new('Foo');\n$stash->addsymbol('%foo', {bar => 1});\n# $Foo::foo{bar} == 1\n$stash->hassymbol('$foo') # false\nmy $namespace = $stash->namespace;\n*{ $namespace->{foo} }{HASH} # {bar => 1}\n\n## DESCRIPTION\n\nManipulating stashes (Perl's symbol tables) is occasionally necessary, but incredibly messy, and\neasy to get wrong. This module hides all of that behind a simple API.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **WORKING WITH VARIABLES**\n- **SEE ALSO**\n- **HISTORY**\n- **BUGS / CAVEATS**\n- **AUTHORS**\n- **CONTRIBUTORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Package::Stash",
        "section": "",
        "mode": "perldoc",
        "summary": "Package::Stash - Routines for manipulating stashes",
        "synopsis": "my $stash = Package::Stash->new('Foo');\n$stash->addsymbol('%foo', {bar => 1});\n# $Foo::foo{bar} == 1\n$stash->hassymbol('$foo') # false\nmy $namespace = $stash->namespace;\n*{ $namespace->{foo} }{HASH} # {bar => 1}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 60,
                "subsections": []
            },
            {
                "name": "WORKING WITH VARIABLES",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "BUGS / CAVEATS",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "CONTRIBUTORS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Package::Stash - Routines for manipulating stashes\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 0.39\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "my $stash = Package::Stash->new('Foo');\n$stash->addsymbol('%foo', {bar => 1});\n# $Foo::foo{bar} == 1\n$stash->hassymbol('$foo') # false\nmy $namespace = $stash->namespace;\n*{ $namespace->{foo} }{HASH} # {bar => 1}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Manipulating stashes (Perl's symbol tables) is occasionally necessary, but incredibly messy, and\neasy to get wrong. This module hides all of that behind a simple API.\n\nNOTE: Most methods in this class require a variable specification that includes a sigil. If this\nsigil is absent, it is assumed to represent the IO slot.\n\nDue to limitations in the typeglob API available to perl code, and to typeglob manipulation in\nperl being quite slow, this module provides two implementations - one in pure perl, and one\nusing XS. The XS implementation is to be preferred for most usages; the pure perl one is\nprovided for cases where XS modules are not a possibility. The current implementation in use can\nbe set by setting $ENV{PACKAGESTASHIMPLEMENTATION} or $Package::Stash::IMPLEMENTATION before\nloading Package::Stash (with the environment variable taking precedence), otherwise, it will use\nthe XS implementation if possible, falling back to the pure perl one.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new $packagename\nCreates a new \"Package::Stash\" object, for the package given as the only argument.\n\nname\nReturns the name of the package that this object represents.\n\nnamespace\nReturns the raw stash itself.\n\naddsymbol $variable $value %opts\nAdds a new package symbol, for the symbol given as $variable, and optionally gives it an initial\nvalue of $value. $variable should be the name of variable including the sigil, so\n\nPackage::Stash->new('Foo')->addsymbol('%foo')\n\nwill create %Foo::foo.\n\nValid options (all optional) are \"filename\", \"firstlinenum\", and \"lastlinenum\".\n\n$opts{filename}, $opts{firstlinenum}, and $opts{lastlinenum} can be used to indicate where\nthe symbol should be regarded as having been defined. Currently these values are only used if\nthe symbol is a subroutine ('\"&\"' sigil) and only if \"$^P & 0x10\" is true, in which case the\nspecial %DB::sub hash is updated to record the values of \"filename\", \"firstlinenum\", and\n\"lastlinenum\" for the subroutine. If these are not passed, their values are inferred (as much\nas possible) from \"caller\" information.\n\nremoveglob $name\nRemoves all package variables with the given name, regardless of sigil.\n\nhassymbol $variable\nReturns whether or not the given package variable (including sigil) exists.\n\ngetsymbol $variable\nReturns the value of the given package variable (including sigil).\n\ngetoraddsymbol $variable\nLike \"getsymbol\", except that it will return an empty hashref or arrayref if the variable\ndoesn't exist.\n\nremovesymbol $variable\nRemoves the package variable described by $variable (which includes the sigil); other variables\nwith the same name but different sigils will be untouched.\n\nlistallsymbols $typefilter\nReturns a list of package variable names in the package, without sigils. If a \"typefilter\" is\npassed, it is used to select package variables of a given type, where valid types are the slots\nof a typeglob ('SCALAR', 'CODE', 'HASH', etc). Note that if the package contained any \"BEGIN\"\nblocks, perl will leave an empty typeglob in the \"BEGIN\" slot, so this will show up if no filter\nis used (and similarly for \"INIT\", \"END\", etc).\n\ngetallsymbols $typefilter\nReturns a hashref, keyed by the variable names in the package. If $typefilter is passed, the\nhash will contain every variable of that type in the package as values, otherwise, it will\ncontain the typeglobs corresponding to the variable names (basically, a clone of the stash).\n\nThis is especially useful for debuggers and profilers, which use %DB::sub to determine where the\nsource code for a subroutine can be found. See\n<http://perldoc.perl.org/perldebguts.html#Debugger-Internals> for more information about\n%DB::sub.\n",
                "subsections": []
            },
            "WORKING WITH VARIABLES": {
                "content": "It is important to note, that when working with scalar variables, the default behavior is to\ncopy values.\n\nmy $stash = Package::Stash->new('Some::Namespace');\nmy $variable = 1;\n# $Some::Namespace::name is a copy of $variable\n$stash->addsymbol('$name', $variable);\n$variable++\n# $Some::Namespace::name == 1 , $variable == 2\n\nThis will likely confuse people who expect it to work the same as typeglob assignment, which\nsimply creates new references to existing variables.\n\nmy $variable = 1;\n{\nno strict 'refs';\n# assign $Package::Stash::name = $variable\n*{'Package::Stash::name'} = \\$variable;\n}\n$variable++ # affects both names\n\nIf this behaviour is desired when working with Package::Stash, simply pass Package::Stash a\nscalar ref:\n\nmy $stash = Package::Stash->new('Some::Namespace');\nmy $variable = 1;\n# $Some::Namespace::name is now $variable\n$stash->addsymbol('$name', \\$variable);\n$variable++\n# $Some::Namespace::name == 2 , $variable == 2\n\nThis will be what you want as well if you're ever working with Readonly variables:\n\nuse Readonly;\nReadonly my $value, 'hello';\n\n$stash->addsymbol('$name', \\$value); # reference\nprint $Some::Namespace::name; # hello\n# Tries to modify the read-only 'hello' and dies.\n$Some::Namespace::name .= \" world\";\n\n$stash->addsymbol('$name', $value); # copy\nprint $Some::Namespace::name; # hello\n# No problem, modifying a copy, not the original\n$Some::Namespace::name .= \" world\";\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   Class::MOP::Package\n\nThis module is a factoring out of code that used to live here\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "Based on code from Class::MOP::Package, by Stevan Little and the Moose Cabal.\n",
                "subsections": []
            },
            "BUGS / CAVEATS": {
                "content": "*   Prior to perl 5.10, scalar slots are only considered to exist if they are defined\n\nThis is due to a shortcoming within perl itself. See \"Making References\" in perlref point 7\nfor more information.\n\n*   GLOB and FORMAT variables are not (yet) accessible through this module.\n\n*   Also, see the BUGS section for the specific backends (Package::Stash::XS and\nPackage::Stash::PP)\n\nBugs may be submitted through the RT bug tracker\n<https://rt.cpan.org/Public/Dist/Display.html?Name=Package-Stash> (or\nbug-Package-Stash@rt.cpan.org <mailto:bug-Package-Stash@rt.cpan.org>).\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   Stevan Little <stevan.little@iinteractive.com>\n\n*   Jesse Luehrs <doy@tozt.net>\n",
                "subsections": []
            },
            "CONTRIBUTORS": {
                "content": "*   Karen Etheridge <ether@cpan.org>\n\n*   Carlos Lima <carlos@multi>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Justin Hunter <justin.d.hunter@gmail.com>\n\n*   Christian Walde <walde.christian@googlemail.com>\n\n*   Kent Fredric <kentfredric@gmail.com>\n\n*   Niko Tyni <ntyni@debian.org>\n\n*   Renee <reb@perl-services.de>\n\n*   Tim Bunce <Tim.Bunce@pobox.com>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2020 by Jesse Luehrs.\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": []
            }
        }
    }
}