info > Class::Inspector

```html

πŸ“– NAME

Class::Inspector - Get information about a class and its structure

πŸš€ Quick Reference

Use CaseCommandDescription
Check if class is installedClass::Inspector->installed('Foo::Class')Returns true if the class is available to Perl.
Check if class is loadedClass::Inspector->loaded('Foo::Class')Returns true if the class is in the symbol table.
Get base filenameClass::Inspector->filename('Foo::Class')Returns path like Foo/Bar.pm (platform‑sensitive).
Get fully resolved filenameClass::Inspector->resolved_filename('Foo::Class')Finds the file that would be used to load the class.
Get actual loaded filenameClass::Inspector->loaded_filename('Foo::Class')Returns the file from %INC that the class was originally loaded from.
List functions in namespaceClass::Inspector->functions('Foo::Class')Returns arrayref of function names (not methods).
Get code references to functionsClass::Inspector->function_refs('Foo::Class')Returns arrayref of CODE refs.
Check if a function existsClass::Inspector->function_exists('Foo::Class', 'bar')Checks function existence (not method).
List all methods for a classClass::Inspector->methods('Foo::Class')Returns arrayref of all method names (inherited).
Find loaded subclassesClass::Inspector->subclasses('Foo::Class')Returns arrayref of classes that isa the given class.

πŸ”– VERSION

version 1.36

πŸ“‹ SYNOPSIS

use Class::Inspector;

# Is a class installed and/or loaded
Class::Inspector->installed( 'Foo::Class' );
Class::Inspector->loaded( 'Foo::Class' );

# Filename related information
Class::Inspector->filename( 'Foo::Class' );
Class::Inspector->resolved_filename( 'Foo::Class' );

# Get subroutine related information
Class::Inspector->functions( 'Foo::Class' );
Class::Inspector->function_refs( 'Foo::Class' );
Class::Inspector->function_exists( 'Foo::Class', 'bar' );
Class::Inspector->methods( 'Foo::Class', 'full', 'public' );

# Find all loaded subclasses or something
Class::Inspector->subclasses( 'Foo::Class' );

πŸ“ DESCRIPTION

Class::Inspector allows you to get information about a loaded class. Most or all of this information can be found in other ways, but they aren't always very friendly, and usually involve a relatively high level of Perl wizardry, or strange and unusual looking code. Class::Inspector attempts to provide an easier, more friendly interface to this information.

βš™οΈ METHODS

πŸ“¦ installed

my $bool = Class::Inspector->installed($class);

The installed static method tries to determine if a class is installed on the machine, or at least available to Perl. It does this by wrapping around resolved_filename.

Returns true if installed/available, false if the class is not installed, or undef if the class name is invalid.

πŸ“₯ loaded

my $bool = Class::Inspector->loaded($class);

The loaded static method tries to determine if a class is loaded by looking for symbol table entries. This method will work even if the class does not have its own file (e.g., multiple classes in one file) or is loaded via run‑time loaders like Autoload or Class::Autouse.

Returns true if the class is loaded, false if not, or undef if the class name is invalid.

πŸ“ filename

my $filename = Class::Inspector->filename($class);

For a given class, returns the base filename (the part below @INC).

print Class->filename( 'Foo::Bar' );
> Foo/Bar.pm

This filename is returned with the correct separator for the local platform.

Returns the filename on success or undef if the class name is invalid.

πŸ” resolved_filename

my $filename = Class::Inspector->resolved_filename($class);
my $filename = Class::Inspector->resolved_filename($class, @try_first);

Returns the fully resolved filename for a class (the file that would be loaded from). This is not necessarily the file that was actually loaded; see loaded_filename for that.

Returns the filename or undef if the class name is invalid.

πŸ“„ loaded_filename

my $filename = Class::Inspector->loaded_filename($class);

For a given loaded class, determines via %INC the name of the file it was originally loaded from.

Returns a resolved file path, or false if the class did not have its own file.

πŸ”§ functions

my $arrayref = Class::Inspector->functions($class);

Returns a list of the names of all functions in the class’s immediate namespace (not methods).

Returns an arrayref of function names on success, or undef if the class is invalid or not loaded.

πŸ”— function_refs

my $arrayref = Class::Inspector->function_refs($class);

Returns references to all functions in the class’s immediate namespace (not methods).

Returns an arrayref of CODE refs on success, or undef if the class is not loaded.

❓ function_exists

my $bool = Class::Inspector->function_exists($class, $functon);

Checks if a function exists in the given class (as a function, not a method). For method existence, use can.

Returns true if the function exists, false if not, or undef if the class is invalid or not loaded.

🧩 methods

my $arrayref = Class::Inspector->methods($class, @options);

Returns ALL methods available to the class (including inherited methods up the @ISA tree).

Returns an arrayref of method names on success, or undef if the class is invalid or not loaded.

Options can be passed after the class name:

[
  [ 'Class::method1',   'Class',   'method1', \&Class::method1   ],
  [ 'Another::method2', 'Another', 'method2', \&Another::method2 ],
  [ 'Foo::bar',         'Foo',     'bar',     \&Foo::bar         ],
]

πŸ” subclasses

my $arrayref = Class::Inspector->subclasses($class);

Searches the entire namespace to find all loaded classes that are subclasses of the given class (via isa).

Returns an arrayref of matching classes, or false if none, or undef if the class name is invalid.

πŸ“š SEE ALSO

πŸ‘€ AUTHOR

Original author: Adam Kennedy <adamk AT cpan.org>

Current maintainer: Graham Ollis <plicease AT cpan.org>

Contributors: Tom Wyant, Steffen MΓΌller, Kivanc Yazan (KYZN)

πŸ“„ COPYRIGHT AND LICENSE

This software is copyright (c) 2002-2019 by Adam Kennedy.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

```
Class::Inspector
πŸ“– NAME πŸš€ Quick Reference πŸ”– VERSION πŸ“‹ SYNOPSIS πŸ“ DESCRIPTION βš™οΈ METHODS
πŸ“¦ installed πŸ“₯ loaded πŸ“ filename πŸ” resolved_filename πŸ“„ loaded_filename πŸ”§ functions πŸ”— function_refs ❓ function_exists 🧩 methods πŸ” subclasses
πŸ“š SEE ALSO πŸ‘€ AUTHOR πŸ“„ COPYRIGHT AND LICENSE

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-16 09:27 @2600:1f28:365:80b0:7cb9:fb:26c1:e368
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!