NAME Class::Inspector - Provides information about Classes 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' ); 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 arn't always very friendly, and usually involve a relatively high level of Perl wizardry, or strange or unusual looking code. Class::Inspector attempts to provide an easier, more friendly interface to this information. METHODS installed( $class ) Tries to determine is a class is installed on the machine, or at least available to Perl. It does this by essentially wrapping around `resolved_filename'. Returns true if installed/available, returns 0 if the class is not installed. Returns undef if the class name is invalid. loaded( $class ) 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 it's own file, but is contained inside a single module with multiple package/classes. Even in the case of some sort of run- time loading class being used, these typically leave some trace in the symbol table, so an `Class::Autouse' or `Autoload' based class should correctly appear loaded. filename( $class ) For a given class, returns the base filename for the class. This will NOT be a fully resolved filename, just the part of the filename BELOW the @INC entry. For example: Class->filename( 'Foo::Bar' ) returns 'Foo/Bar.pm' This filename will be returned for the current platform. It should work on all platforms. Returns the filename on success. Returns undef on error, which could only really be caused by an invalid class name. resolved_filename( $class, @try_first ) For a given class, returns the fully resolved filename for a class. That is, the file that the class would be loaded from. This is not nescesarily the file that the class WAS loaded from, as the value returned is determined each time it runs, and the @INC include path may change. To get the actual file for a loaded class, see the `loaded_filename' method. Returns the filename for the class on success. Returns undef on error. loaded_filename( $class ) For a given, loaded, class, returns the name of the file that it was originally loaded from. Returns false if the class is not loaded, or did not have it's own file. functions( $class ) Returns a list of the names of all the functions in the classes immediate namespace. Note that this is not the METHODS of the class, just the functions. Returns a reference to an array of the function names on success. Returns undef on error or if the class is not loaded. function_refs( $class ) Returns a list of references to all the functions in the classes immediate namespace. Returns a reference to an array of CODE refs of the functions on success. Returns undef on error or if the class is not loaded. function_exists( $class, $function ) Given a class and function the `function_exists' method will check to see if the function exists in the class. Note that this is as a function, not as a method. To see if a method exists for a class, use the `can' method in UNIVERSAL, and hence to every other class. Returns 1 if the function exists. Returns 0 if the function does not exist. Returns undef on error, or if the class is not loaded. methods( $class ) For a given class name, the `methods' method will returns ALL the methods available to that class. This includes all methods available from every class up the classes `@ISA' tree. Returns a reference to an array of the names of all the available methods on success. Returns undef if the class is not loaded. BUGS No known bugs, but I'm taking suggestions for additional functionality. SUPPORT Contact the author AUTHOR Adam Kennedy cpan@ali.as http://ali.as/ SEE ALSO Class::Handle, which wraps this one COPYRIGHT Copyright (c) 2002 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module.