{
    "content": [
        {
            "type": "text",
            "text": "# UNIVERSAL (man)\n\n## NAME\n\nUNIVERSAL - base class for ALL classes (blessed references)\n\n## SYNOPSIS\n\n$isio    = $fd->isa(\"IO::Handle\");\n$isio    = Class->isa(\"IO::Handle\");\n$doeslog = $obj->DOES(\"Logger\");\n$doeslog = Class->DOES(\"Logger\");\n$sub      = $obj->can(\"print\");\n$sub      = Class->can(\"print\");\n$sub      = eval { $ref->can(\"fandango\") };\n$ver      = $obj->VERSION;\n# but never do this!\n$isio    = UNIVERSAL::isa($fd, \"IO::Handle\");\n$sub      = UNIVERSAL::can($obj, \"print\");\n\n## DESCRIPTION\n\n\"UNIVERSAL\" is the base class from which all blessed references inherit.  See perlobj.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **WARNINGS**\n- **EXPORTS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "UNIVERSAL",
        "section": "",
        "mode": "man",
        "summary": "UNIVERSAL - base class for ALL classes (blessed references)",
        "synopsis": "$isio    = $fd->isa(\"IO::Handle\");\n$isio    = Class->isa(\"IO::Handle\");\n$doeslog = $obj->DOES(\"Logger\");\n$doeslog = Class->DOES(\"Logger\");\n$sub      = $obj->can(\"print\");\n$sub      = Class->can(\"print\");\n$sub      = eval { $ref->can(\"fandango\") };\n$ver      = $obj->VERSION;\n# but never do this!\n$isio    = UNIVERSAL::isa($fd, \"IO::Handle\");\n$sub      = UNIVERSAL::can($obj, \"print\");",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 97,
                "subsections": []
            },
            {
                "name": "WARNINGS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 22,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "UNIVERSAL - base class for ALL classes (blessed references)\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "$isio    = $fd->isa(\"IO::Handle\");\n$isio    = Class->isa(\"IO::Handle\");\n\n$doeslog = $obj->DOES(\"Logger\");\n$doeslog = Class->DOES(\"Logger\");\n\n$sub      = $obj->can(\"print\");\n$sub      = Class->can(\"print\");\n\n$sub      = eval { $ref->can(\"fandango\") };\n$ver      = $obj->VERSION;\n\n# but never do this!\n$isio    = UNIVERSAL::isa($fd, \"IO::Handle\");\n$sub      = UNIVERSAL::can($obj, \"print\");\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "\"UNIVERSAL\" is the base class from which all blessed references inherit.  See perlobj.\n\n\"UNIVERSAL\" provides the following methods:\n\n\"$obj->isa( TYPE )\"\n\"CLASS->isa( TYPE )\"\n\"eval { VAL->isa( TYPE ) }\"\nWhere\n\n\"TYPE\"\nis a package name\n\n$obj\nis a blessed reference or a package name\n\n\"CLASS\"\nis a package name\n\n\"VAL\"\nis any of the above or an unblessed reference\n\nWhen used as an instance or class method (\"$obj->isa( TYPE )\"), \"isa\" returns true if\n$obj is blessed into package \"TYPE\" or inherits from package \"TYPE\".\n\nWhen used as a class method (\"CLASS->isa( TYPE )\", sometimes referred to as a static\nmethod), \"isa\" returns true if \"CLASS\" inherits from (or is itself) the name of the\npackage \"TYPE\" or inherits from package \"TYPE\".\n\nIf you're not sure what you have (the \"VAL\" case), wrap the method call in an \"eval\"\nblock to catch the exception if \"VAL\" is undefined.\n\nIf you want to be sure that you're calling \"isa\" as a method, not a class, check the\ninvocand with \"blessed\" from Scalar::Util first:\n\nuse Scalar::Util 'blessed';\n\nif ( blessed( $obj ) && $obj->isa(\"Some::Class\") ) {\n...\n}\n\n\"$obj->DOES( ROLE )\"\n\"CLASS->DOES( ROLE )\"\n\"DOES\" checks if the object or class performs the role \"ROLE\".  A role is a named group\nof specific behavior (often methods of particular names and signatures), similar to a\nclass, but not necessarily a complete class by itself.  For example, logging or\nserialization may be roles.\n\n\"DOES\" and \"isa\" are similar, in that if either is true, you know that the object or\nclass on which you call the method can perform specific behavior.  However, \"DOES\" is\ndifferent from \"isa\" in that it does not care how the invocand performs the operations,\nmerely that it does.  (\"isa\" of course mandates an inheritance relationship.  Other\nrelationships include aggregation, delegation, and mocking.)\n\nBy default, classes in Perl only perform the \"UNIVERSAL\" role, as well as the role of all\nclasses in their inheritance.  In other words, by default \"DOES\" responds identically to\n\"isa\".\n\nThere is a relationship between roles and classes, as each class implies the existence of\na role of the same name.  There is also a relationship between inheritance and roles, in\nthat a subclass that inherits from an ancestor class implicitly performs any roles its\nparent performs.  Thus you can use \"DOES\" in place of \"isa\" safely, as it will return\ntrue in all places where \"isa\" will return true (provided that any overridden \"DOES\" and\n\"isa\" methods behave appropriately).\n\n\"$obj->can( METHOD )\"\n\"CLASS->can( METHOD )\"\n\"eval { VAL->can( METHOD ) }\"\n\"can\" checks if the object or class has a method called \"METHOD\". If it does, then it\nreturns a reference to the sub.  If it does not, then it returns undef.  This includes\nmethods inherited or imported by $obj, \"CLASS\", or \"VAL\".\n\n\"can\" cannot know whether an object will be able to provide a method through AUTOLOAD\n(unless the object's class has overridden \"can\" appropriately), so a return value of\nundef does not necessarily mean the object will not be able to handle the method call. To\nget around this some module authors use a forward declaration (see perlsub) for methods\nthey will handle via AUTOLOAD. For such 'dummy' subs, \"can\" will still return a code\nreference, which, when called, will fall through to the AUTOLOAD. If no suitable AUTOLOAD\nis provided, calling the coderef will cause an error.\n\nYou may call \"can\" as a class (static) method or an object method.\n\nAgain, the same rule about having a valid invocand applies -- use an \"eval\" block or\n\"blessed\" if you need to be extra paranoid.\n\n\"VERSION ( [ REQUIRE ] )\"\n\"VERSION\" will return the value of the variable $VERSION in the package the object is\nblessed into. If \"REQUIRE\" is given then it will do a comparison and die if the package\nversion is not greater than or equal to \"REQUIRE\", or if either $VERSION or \"REQUIRE\" is\nnot a \"lax\" version number (as defined by the version module).\n\nThe return from \"VERSION\" will actually be the stringified version object using the\npackage $VERSION scalar, which is guaranteed to be equivalent but may not be precisely\nthe contents of the $VERSION scalar.  If you want the actual contents of $VERSION, use\n$CLASS::VERSION instead.\n\n\"VERSION\" can be called as either a class (static) method or an object method.\n",
                "subsections": []
            },
            "WARNINGS": {
                "content": "NOTE: \"can\" directly uses Perl's internal code for method lookup, and \"isa\" uses a very\nsimilar method and cache-ing strategy. This may cause strange effects if the Perl code\ndynamically changes @ISA in any package.\n\nYou may add other methods to the UNIVERSAL class via Perl or XS code.  You do not need to\n\"use UNIVERSAL\" to make these methods available to your program (and you should not do so).\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "None.\n\nPrevious versions of this documentation suggested using \"isa\" as a function to determine the\ntype of a reference:\n\n$yes = UNIVERSAL::isa($h, \"HASH\");\n$yes = UNIVERSAL::isa(\"Foo\", \"Bar\");\n\nThe problem is that this code would never call an overridden \"isa\" method in any class.\nInstead, use \"reftype\" from Scalar::Util for the first case:\n\nuse Scalar::Util 'reftype';\n\n$yes = reftype( $h ) eq \"HASH\";\n\nand the method form of \"isa\" for the second:\n\n$yes = Foo->isa(\"Bar\");\n\n\n\nperl v5.34.0                                 2025-07-25                             UNIVERSAL(3perl)",
                "subsections": []
            }
        }
    }
}