{
    "mode": "perldoc",
    "parameter": "Template::Stash::Context",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AStash%3A%3AContext/json",
    "generated": "2026-10-09T12:36:05Z",
    "synopsis": "use Template;\nuse Template::Stash::Context;\nmy $stash = Template::Stash::Context->new(\\%vars);\nmy $tt2   = Template->new({ STASH => $stash });",
    "sections": {
        "NAME": {
            "content": "Template::Stash::Context - Experimetal stash allowing list/scalar context definition\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Template;\nuse Template::Stash::Context;\n\nmy $stash = Template::Stash::Context->new(\\%vars);\nmy $tt2   = Template->new({ STASH => $stash });\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is an alternate stash object which includes a patch from Craig Barratt to implement various\nnew virtual methods to allow dotted template variable to denote if object methods and\nsubroutines should be called in scalar or list context. It adds a little overhead to each stash\ncall and I'm a little wary of applying that to the core default stash without investigating the\neffects first. So for now, it's implemented as a separate stash module which will allow us to\ntest it out, benchmark it and switch it in or out as we require.\n\nThis is what Craig has to say about it:\n\nHere's a better set of features for the core. Attached is a new version of Stash.pm (based on\nTT2.02) that:\n\n* supports the special op \"scalar\" that forces scalar context on function calls, eg:\n\ncgi.param(\"foo\").scalar\n\ncalls cgi.param(\"foo\") in scalar context (unlike my wimpy scalar op from last night). Array\ncontext is the default.\n\nWith non-function operands, scalar behaves like the perl version (eg: no-op for scalar, size for\narrays, etc).\n\n* supports the special op \"ref\" that behaves like the perl ref. If applied to a function the\nfunction is not called. Eg:\n\ncgi.param(\"foo\").ref\n\ndoes *not* call cgi.param and evaluates to \"CODE\". Similarly, HASH.ref, ARRAY.ref return what\nyou expect.\n\n* adds a new scalar and list op called \"array\" that is a no-op for arrays and promotes scalars\nto one-element arrays.\n\n* allows scalar ops to be applied to arrays and hashes in place, eg: ARRAY.repeat(3) repeats\neach element in place.\n\n* allows list ops to be applied to scalars by promoting the scalars to one-element arrays (like\nan implicit \"array\"). So you can do things like SCALAR.size, SCALAR.join and get a useful\nresult.\n\nThis also means you can now use x.0 to safely get the first element whether x is an array or\nscalar.\n\nThe new Stash.pm passes the TT2.02 test suite. But I haven't tested the new features very much.\nOne nagging implementation problem is that the \"scalar\" and \"ref\" ops have higher precedence\nthan user variable names.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Andy Wardley <abw@wardley.org>\n\n<http://wardley.org/>\n",
            "subsections": []
        },
        "VERSION": {
            "content": "1.63, distributed as part of the Template Toolkit version 2.19, released on 27 April 2007.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Template::Stash\n",
            "subsections": []
        }
    },
    "summary": "Template::Stash::Context - Experimetal stash allowing list/scalar context definition",
    "flags": [],
    "examples": [],
    "see_also": []
}