|
MRP::Introspection - powerful introspection |
MRP::Introspection - powerful introspection
Provides introspection support without you breaking strict.
These functions perform introspection into a package to avoid you having to tamper with the symbol table directly. They use MAJOR wizardry to make sure that things behave just as you would expect. Use with caution, particularly if you use them to alter variables.
$arrayHash = MRP::Interface->_arrays($obj);
print "Got ISA ", $arrayHash->{ISA}, "\n";
%arrayHash = MRP::Interface->_functions(MyPackage);
print "Found ISA" if exists $arrayHash{'ISA'}
$func = MRP::Interface->_function($thingy, 'printme');
will put a reference to the function 'printme' in $func. If there is no such function within the package that $thingy is blessed into (or the package named by $thingy), then $func will be undef. These functions do not deal with inheritance. They only look in a single package.
$symTable = MRP::Introspection->symTable($obj);
$isaRef = MRP::Introspection->ISA($package); push @$isaRef, $newBaseClass;
$sets = MRP::Introspection($package, '^set.*$'); # all the functions in
# package $package matching ^set.*$
Recursively applies a function throughout an objects inheritance hierachy. Returns a hash or hashref of all of the function return values pre-catonated with the package name. You will have to just try this one out.
$autref = MRP::Interface->superAutoload($thisPackage, $AUTOLOAD); $autref->(@paramlist);
For those stickey moments when you have entered an AUTOLOAD method, but it needs to allow some superclasses AUTOLOAD to do some processing. The method sets $AUTOLOAD in the package that is first reached by inheritance that has an AUTOLOAD method, and returns a reference to that function. You just have to use the reference and pass it the relevant arguments.
Matthew Pocock mrp@sanger.ac.uk
|
MRP::Introspection - powerful introspection |