1B::Xref(3pm)           Perl Programmers Reference Guide           B::Xref(3pm)
2
3
4

NAME

6       B::Xref - Generates cross reference reports for Perl programs
7

SYNOPSIS

9       perl -MO=Xref[,OPTIONS] foo.pl
10

DESCRIPTION

12       The B::Xref module is used to generate a cross reference listing of all
13       definitions and uses of variables, subroutines and formats in a Perl
14       program.  It is implemented as a backend for the Perl compiler.
15
16       The report generated is in the following format:
17
18           File filename1
19             Subroutine subname1
20               Package package1
21                 object1        line numbers
22                 object2        line numbers
23                 ...
24               Package package2
25               ...
26
27       Each File section reports on a single file. Each Subroutine section
28       reports on a single subroutine apart from the special cases
29       "(definitions)" and "(main)". These report, respectively, on subroutine
30       definitions found by the initial symbol table walk and on the main part
31       of the program or module external to all subroutines.
32
33       The report is then grouped by the Package of each variable, subroutine
34       or format with the special case "(lexicals)" meaning lexical variables.
35       Each object name (implicitly qualified by its containing Package)
36       includes its type character(s) at the beginning where possible. Lexical
37       variables are easier to track and even included dereferencing
38       information where possible.
39
40       The "line numbers" are a comma separated list of line numbers (some
41       preceded by code letters) where that object is used in some way.
42       Simple uses aren't preceded by a code letter. Introductions (such as
43       where a lexical is first defined with "my") are indicated with the
44       letter "i". Subroutine and method calls are indicated by the character
45       "&".  Subroutine definitions are indicated by "s" and format
46       definitions by "f".
47
48       For instance, here's part of the report from the pod2man program that
49       comes with Perl:
50
51         Subroutine clear_noremap
52           Package (lexical)
53             $ready_to_print   i1069, 1079
54           Package main
55             $&                1086
56             $.                1086
57             $0                1086
58             $1                1087
59             $2                1085, 1085
60             $3                1085, 1085
61             $ARGV             1086
62             %HTML_Escapes     1085, 1085
63
64       This shows the variables used in the subroutine "clear_noremap".  The
65       variable $ready_to_print is a my() (lexical) variable, introduced
66       (first declared with my()) on line 1069, and used on line 1079.  The
67       variable $& from the main package is used on 1086, and so on.
68
69       A line number may be prefixed by a single letter:
70
71       i   Lexical variable introduced (declared with my()) for the first
72           time.
73
74       &   Subroutine or method call.
75
76       s   Subroutine defined.
77
78       r   Format defined.
79
80       The most useful option the cross referencer has is to save the report
81       to a separate file.  For instance, to save the report on myperlprogram
82       to the file report:
83
84         $ perl -MO=Xref,-oreport myperlprogram
85

OPTIONS

87       Option words are separated by commas (not whitespace) and follow the
88       usual conventions of compiler backend options.
89
90       "-oFILENAME"
91               Directs output to "FILENAME" instead of standard output.
92
93       "-r"    Raw output. Instead of producing a human-readable report,
94               outputs a line in machine-readable form for each definition/use
95               of a variable/sub/format.
96
97       "-d"    Don't output the "(definitions)" sections.
98
99       "-D[tO]"
100               (Internal) debug options, probably only useful if "-r"
101               included.  The "t" option prints the object on the top of the
102               stack as it's being tracked. The "O" option prints each
103               operator as it's being processed in the execution order of the
104               program.
105

BUGS

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

AUTHOR

113       Malcolm Beattie, mbeattie@sable.ox.ac.uk.
114
115
116
117perl v5.30.1                      2019-11-29                      B::Xref(3pm)
Impressum