Sepia::Xref(3) Generates cross reference database for use by Perl programs.


use Sepia::Xref qw(rebuild defs callers);
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];


"Sepia::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.


A map of subs to call locations and callers
A map of subs to subs called.
A map of global/package variables to uses.
A map of global/package variables to definitions (usually empty, since it only picks up local (...) declarations.


"guess_module_file($pack, $ofile)"
XXX: it turns out that rooting around trying to figure out the file ourselves is more reliable than what we grab from the op. Are we doing this wrong?
Rebuild the Xref database.
"forget($func [, $mod])"
Forget that $func was defined.
"redefined($func [, $pack])"
Recompute xref info for $func, or "$pack::$func" if $pack given.
List callers of $func.
List callees of $func.
Find locations where $var is defined.
Find locations where $var is used.
Find locations where $var is assigned to.
List the modules defined in file $file.
Find variables matching $expr.


Nothing by default, but all sub and variable described above can be imported. "Sepia::Xref" also defines the tags ":most" for the above-listed functions, and ":all" for those and the variables as well.


See B::Xref.
module names are ignored when looking up a sub.
file and line number guessing is evil
Both should be done more cleanly and effectively. This is a hack because I don't quite understand what perl saves. We should be able to do as well as its warning messages.
Some packages are not xref'd.
Some ``internal'' packages are deliberately not cross-referenced, either because they are hairy and cause us problems, or because they are so commonly included as to be uninteresting. The current list includes all pragmatic modules, plus: B, O, AutoLoader, DynaLoader, XSLoader, Config, DB, VMS, FileHandle, Exporter, Carp, PerlIO::Layer.
Tree-view is not fully functional
Ideally, clicking the function names in tree view would take you to that function. This doesn't work. Also, more keys (like ``q'' to quit) should be implemented.


B::Xref by Malcolm Beattie, m(angl|odifi)ed by Sean O'Rourke ([email protected]).