Devel::Xref - Generates cross reference database for use by Perl programs.
use Devel::Xref qw(rebuild defs callers); rebuild; for (defs 'foo') { printf "%s:%d: sub %s\::foo() defined\n", @{$_}[0..2]; } for (callers 'foo') { printf "%s:%d: sub foo() called by %s\::%s().\n", @{$_}[0..3]; }
Devel::Xref is intended as a programmatic interface to the information supplied by B::Xref. It is intended to be a component for interactive Perl development, with other packages providing a friendly interface to the raw information it extracts. B::Xref could be seen as an example of this sort of user-level tool, if it weren't for the fact that this module was created later, and stole most of its code.
Devel::Xref
B::Xref
%call
A map of subs to call locations and callers
%callby
A map of subs to subs called.
%def
A map of subs to definitions.
%module_subs
A map of packages to subs defined.
%var_use
A map of global/package variables to uses.
%var_def
A map of global/package variables to definitions (usually empty, since it only picks up local (...) declarations.
%module_files
A map of module names to containing files.
%file_modules
A map of files to module names.
rebuild()
Rebuild the Xref database.
forget($func [, $mod])
Forget that $func was defined.
$func
redefined($func [, $pack])
Recompute xref info for each of of @funcs.
@funcs
callers($func)
List callers of $func.
callees($func)
List callees of $func.
defs($func)
Find locations where $func is defined.
var_defs($var)
Find locations where $var is defined.
$var
var_uses($var)
Find locations where $var is used.
var_assigns($var)
Find locations where $var is assigned to.
mod_subs($pack)
Find subs in package $pack.
$pack
mod_decls($pack)
Generate a list of declarations for all subroutines in package $pack.
mod_file($mod)
Find file for module $mod.
$mod
file_modules($file)
List the modules defined in file $file.
$file
apropos($expr)
Find subs matching $expr.
$expr
var_apropos($expr)
Find variables matching $expr.
mod_apropos($expr)
Find modules matching $expr.
file_apropos($expr)
Nothing by default, but all sub and variable described above can be imported. Devel::Xref also defines the tags :most for the above-listed functions, and :all for those and the variables as well.
:most
:all
See B::Xref. Also, we currently ignore module names when looking up a sub by name. Finally, there is some evil in the way we guess file and line numbers, both of which should be done more cleanly and effectively.
B::Xref, from which Devel::Xref is heavily derivative.
B::Xref by Malcolm Beattie, m(angl|odifi)ed by Sean O'Rourke (seano@cpan.org).
To install Devel::Xref, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Xref
CPAN shell
perl -MCPAN -e shell install Devel::Xref
For more information on module installation, please visit the detailed CPAN module installation guide.