{
    "mode": "perldoc",
    "parameter": "Class::Inspector",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AInspector/json",
    "generated": "2026-06-11T18:36:02Z",
    "synopsis": "use Class::Inspector;\n# Is a class installed and/or loaded\nClass::Inspector->installed( 'Foo::Class' );\nClass::Inspector->loaded( 'Foo::Class' );\n# Filename related information\nClass::Inspector->filename( 'Foo::Class' );\nClass::Inspector->resolvedfilename( 'Foo::Class' );\n# Get subroutine related information\nClass::Inspector->functions( 'Foo::Class' );\nClass::Inspector->functionrefs( 'Foo::Class' );\nClass::Inspector->functionexists( 'Foo::Class', 'bar' );\nClass::Inspector->methods( 'Foo::Class', 'full', 'public' );\n# Find all loaded subclasses or something\nClass::Inspector->subclasses( 'Foo::Class' );",
    "sections": {
        "NAME": {
            "content": "Class::Inspector - Get information about a class and its structure\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 1.36\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Class::Inspector;\n\n# Is a class installed and/or loaded\nClass::Inspector->installed( 'Foo::Class' );\nClass::Inspector->loaded( 'Foo::Class' );\n\n# Filename related information\nClass::Inspector->filename( 'Foo::Class' );\nClass::Inspector->resolvedfilename( 'Foo::Class' );\n\n# Get subroutine related information\nClass::Inspector->functions( 'Foo::Class' );\nClass::Inspector->functionrefs( 'Foo::Class' );\nClass::Inspector->functionexists( 'Foo::Class', 'bar' );\nClass::Inspector->methods( 'Foo::Class', 'full', 'public' );\n\n# Find all loaded subclasses or something\nClass::Inspector->subclasses( 'Foo::Class' );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Class::Inspector allows you to get information about a loaded class. Most or all of this\ninformation can be found in other ways, but they aren't always very friendly, and usually\ninvolve a relatively high level of Perl wizardry, or strange and unusual looking code.\nClass::Inspector attempts to provide an easier, more friendly interface to this information.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "installed\nmy $bool = Class::Inspector->installed($class);\n\nThe \"installed\" static method tries to determine if a class is installed on the machine, or at\nleast available to Perl. It does this by wrapping around \"resolvedfilename\".\n\nReturns true if installed/available, false if the class is not installed, or \"undef\" if the\nclass name is invalid.\n\nloaded\nmy $bool = Class::Inspector->loaded($class);\n\nThe \"loaded\" static method tries to determine if a class is loaded by looking for symbol table\nentries.\n\nThis method it uses to determine this will work even if the class does not have its own file,\nbut is contained inside a single file with multiple classes in it. Even in the case of some sort\nof run-time loading class being used, these typically leave some trace in the symbol table, so\nan Autoload or Class::Autouse-based class should correctly appear loaded.\n\nReturns true if the class is loaded, false if not, or \"undef\" if the class name is invalid.\n\nfilename\nmy $filename = Class::Inspector->filename($class);\n\nFor a given class, returns the base filename for the class. This will NOT be a fully resolved\nfilename, just the part of the filename BELOW the @INC entry.\n\nprint Class->filename( 'Foo::Bar' );\n> Foo/Bar.pm\n\nThis filename will be returned with the right separator for the local platform, and should work\non all platforms.\n\nReturns the filename on success or \"undef\" if the class name is invalid.\n\nresolvedfilename\nmy $filename = Class::Inspector->resolvedfilename($class);\nmy $filename = Class::Inspector->resolvedfilename($class, @tryfirst);\n\nFor a given class, the \"resolvedfilename\" static method returns the fully resolved filename for\na class. That is, the file that the class would be loaded from.\n\nThis is not necessarily the file that the class WAS loaded from, as the value returned is\ndetermined each time it runs, and the @INC include path may change.\n\nTo get the actual file for a loaded class, see the \"loadedfilename\" method.\n\nReturns the filename for the class, or \"undef\" if the class name is invalid.\n\nloadedfilename\nmy $filename = Class::Inspector->loadedfilename($class);\n\nFor a given loaded class, the \"loadedfilename\" static method determines (via the %INC hash) the\nname of the file that it was originally loaded from.\n\nReturns a resolved file path, or false if the class did not have it's own file.\n\nfunctions\nmy $arrayref = Class::Inspector->functions($class);\n\nFor a loaded class, the \"functions\" static method returns a list of the names of all the\nfunctions in the classes immediate namespace.\n\nNote that this is not the METHODS of the class, just the functions.\n\nReturns a reference to an array of the function names on success, or \"undef\" if the class name\nis invalid or the class is not loaded.\n\nfunctionrefs\nmy $arrayref = Class::Inspector->functionrefs($class);\n\nFor a loaded class, the \"functionrefs\" static method returns references to all the functions in\nthe classes immediate namespace.\n\nNote that this is not the METHODS of the class, just the functions.\n\nReturns a reference to an array of \"CODE\" refs of the functions on success, or \"undef\" if the\nclass is not loaded.\n\nfunctionexists\nmy $bool = Class::Inspector->functionexists($class, $functon);\n\nGiven a class and function name the \"functionexists\" static method will check to see if the\nfunction exists in the class.\n\nNote that this is as a function, not as a method. To see if a method exists for a class, use the\n\"can\" method for any class or object.\n\nReturns true if the function exists, false if not, or \"undef\" if the class or function name are\ninvalid, or the class is not loaded.\n\nmethods\nmy $arrayref = Class::Inspector->methods($class, @options);\n\nFor a given class name, the \"methods\" static method will returns ALL the methods available to\nthat class. This includes all methods available from every class up the class' @ISA tree.\n\nReturns a reference to an array of the names of all the available methods on success, or \"undef\"\nif the class name is invalid or the class is not loaded.\n\nA number of options are available to the \"methods\" method that will alter the results returned.\nThese should be listed after the class name, in any order.\n\n# Only get public methods\nmy $method = Class::Inspector->methods( 'My::Class', 'public' );\n\npublic\nThe \"public\" option will return only 'public' methods, as defined by the Perl convention of\nprepending an underscore to any 'private' methods. The \"public\" option will effectively\nremove any methods that start with an underscore.\n\nprivate\nThe \"private\" options will return only 'private' methods, as defined by the Perl convention\nof prepending an underscore to an private methods. The \"private\" option will effectively\nremove an method that do not start with an underscore.\n\nNote: The \"public\" and \"private\" options are mutually exclusive\n\nfull\n\"methods\" normally returns just the method name. Supplying the \"full\" option will cause the\nmethods to be returned as the full names. That is, instead of returning \"[ 'method1',\n'method2', 'method3' ]\", you would instead get \"[ 'Class::method1', 'AnotherClass::method2',\n'Class::method3' ]\".\n\nexpanded\nThe \"expanded\" option will cause a lot more information about method to be returned. Instead\nof just the method name, you will instead get an array reference containing the method name\nas a single combined name, a la \"full\", the separate class and method, and a CODE ref to the\nactual function ( if available ). Please note that the function reference is not guaranteed\nto be available. \"Class::Inspector\" is intended at some later time, to work with modules\nthat have some kind of common run-time loader in place ( e.g \"Autoloader\" or\n\"Class::Autouse\" for example.\n\nThe response from \"methods( 'Class', 'expanded' )\" would look something like the following.\n\n[\n[ 'Class::method1',   'Class',   'method1', \\&Class::method1   ],\n[ 'Another::method2', 'Another', 'method2', \\&Another::method2 ],\n[ 'Foo::bar',         'Foo',     'bar',     \\&Foo::bar         ],\n]\n\nsubclasses\nmy $arrayref = Class::Inspector->subclasses($class);\n\nThe \"subclasses\" static method will search then entire namespace (and thus all currently loaded\nclasses) to find all classes that are subclasses of the class provided as a the parameter.\n\nThe actual test will be done by calling \"isa\" on the class as a static method. (i.e.\n\"My::Class->isa($class)\".\n\nReturns a reference to a list of the loaded classes that match the class provided, or false is\nnone match, or \"undef\" if the class name provided is invalid.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "<http://ali.as/>, Class::Handle, Class::Inspector::Functions\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Original author: Adam Kennedy <adamk@cpan.org>\n\nCurrent maintainer: Graham Ollis <plicease@cpan.org>\n\nContributors:\n\nTom Wyant\n\nSteffen Müller\n\nKivanc Yazan (KYZN)\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2002-2019 by Adam Kennedy.\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": "Class::Inspector - Get information about a class and its structure",
    "flags": [],
    "examples": [],
    "see_also": []
}