# perldoc > B::Xref

---
type: CommandReference
command: B::Xref
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `perl -MO=Xref foo.pl` — Generate cross reference report for *foo.pl*
- `perl -MO=Xref,-oreport foo.pl` — Save report to file *report*
- `perl -MO=Xref,-r foo.pl` — Output raw machine-readable form
- `perl -MO=Xref,-d foo.pl` — Omit "(definitions)" sections
- `perl -MO=Xref,-D[tO] foo.pl` — Internal debug options (requires `-r`)

## Name

Generates cross reference reports for Perl programs.

## Synopsis

shell
perl -MO=Xref[,OPTIONS] foo.pl
## Options

- `-oFILENAME` — Direct output to *FILENAME* instead of standard output.
- `-r` — Raw output. Produces a machine-readable line for each definition/use of a variable/sub/format instead of a human-readable report.
- `-d` — Don't output the "(definitions)" sections.
- `-D[tO]` — Internal debug options (only useful with `-r`). `t` prints the object on top of the stack; `O` prints each operator as processed in execution order.

## Examples

Generate a cross reference report for *pod2man* (from the Perl distribution) and examine part of the output:

shell
perl -MO=Xref -e 'use Pod::Man; ...' pod2man
Partial output:

Subroutine clear_noremap
  Package (lexical)
    $ready_to_print   i1069, 1079
  Package main
    $&                1086
    $.                1086
    $0                1086
    $1                1087
    $2                1085, 1085
    $3                1085, 1085
    $ARGV             1086
    %HTML_Escapes     1085, 1085
Line numbers may be prefixed by a single letter:
- `i` — Lexical variable introduced (declared with `my()`) for the first time.
- `&` — Subroutine or method call.
- `s` — Subroutine defined.
- `r` — Format defined.

## See Also

- [B::Xref on perldoc](https://perldoc.perl.org/B::Xref)

## Exit Codes

None documented.

## Bugs

Non-lexical variables are difficult to track through a program. Sometimes the type of a non-lexical variable's use is impossible to determine. Introductions of non-lexical non-scalars don't seem to be reported properly.