Debian Codegraph @

upstream/opensuse-tumbleweed/man3/B::Xref.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "B::Xref 3pm"
61 .TH B::Xref 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 B::Xref \- Generates cross reference reports for Perl programs
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 perl \-MO=Xref[,OPTIONS] foo.pl
71 .SH DESCRIPTION
72 .IX Header "DESCRIPTION"
73 The B::Xref module is used to generate a cross reference listing of all
74 definitions and uses of variables, subroutines and formats in a Perl program.
75 It is implemented as a backend for the Perl compiler.
76 .PP
77 The report generated is in the following format:
78 .PP
79 .Vb 8
80 \& File filename1
81 \& Subroutine subname1
82 \& Package package1
83 \& object1 line numbers
84 \& object2 line numbers
85 \& ...
86 \& Package package2
87 \& ...
88 .Ve
89 .PP
90 Each \fBFile\fR section reports on a single file. Each \fBSubroutine\fR section
91 reports on a single subroutine apart from the special cases
92 "(definitions)" and "(main)". These report, respectively, on subroutine
93 definitions found by the initial symbol table walk and on the main part of
94 the program or module external to all subroutines.
95 .PP
96 The report is then grouped by the \fBPackage\fR of each variable,
97 subroutine or format with the special case "(lexicals)" meaning
98 lexical variables. Each \fBobject\fR name (implicitly qualified by its
99 containing \fBPackage\fR) includes its type character(s) at the beginning
100 where possible. Lexical variables are easier to track and even
101 included dereferencing information where possible.
102 .PP
103 The \f(CW\*(C`line numbers\*(C'\fR are a comma separated list of line numbers (some
104 preceded by code letters) where that object is used in some way.
105 Simple uses aren\*(Aqt preceded by a code letter. Introductions (such as
106 where a lexical is first defined with \f(CW\*(C`my\*(C'\fR) are indicated with the
107 letter "i". Subroutine and method calls are indicated by the character
108 "&". Subroutine definitions are indicated by "s" and format
109 definitions by "f".
110 .PP
111 For instance, here\*(Aqs part of the report from the \fIpod2man\fR program that
112 comes with Perl:
113 .PP
114 .Vb 12
115 \& Subroutine clear_noremap
116 \& Package (lexical)
117 \& $ready_to_print i1069, 1079
118 \& Package main
119 \& $& 1086
120 \& $. 1086
121 \& $0 1086
122 \& $1 1087
123 \& $2 1085, 1085
124 \& $3 1085, 1085
125 \& $ARGV 1086
126 \& %HTML_Escapes 1085, 1085
127 .Ve
128 .PP
129 This shows the variables used in the subroutine \f(CW\*(C`clear_noremap\*(C'\fR. The
130 variable \f(CW$ready_to_print\fR is a \fBmy()\fR (lexical) variable,
131 \&\fBi\fRntroduced (first declared with \fBmy()\fR) on line 1069, and used on
132 line 1079. The variable \f(CW$&\fR from the main package is used on 1086,
133 and so on.
134 .PP
135 A line number may be prefixed by a single letter:
136 .IP i 4
137 .IX Item "i"
138 Lexical variable introduced (declared with \fBmy()\fR) for the first time.
139 .IP & 4
140 Subroutine or method call.
141 .IP s 4
142 .IX Item "s"
143 Subroutine defined.
144 .IP r 4
145 .IX Item "r"
146 Format defined.
147 .PP
148 The most useful option the cross referencer has is to save the report
149 to a separate file. For instance, to save the report on
150 \&\fImyperlprogram\fR to the file \fIreport\fR:
151 .PP
152 .Vb 1
153 \& $ perl \-MO=Xref,\-oreport myperlprogram
154 .Ve
155 .SH OPTIONS
156 .IX Header "OPTIONS"
157 Option words are separated by commas (not whitespace) and follow the
158 usual conventions of compiler backend options.
159 .ie n .IP """\-oFILENAME""" 8
160 .el .IP \f(CW\-oFILENAME\fR 8
161 .IX Item "-oFILENAME"
162 Directs output to \f(CW\*(C`FILENAME\*(C'\fR instead of standard output.
163 .ie n .IP """\-r""" 8
164 .el .IP \f(CW\-r\fR 8
165 .IX Item "-r"
166 Raw output. Instead of producing a human\-readable report, outputs a line
167 in machine\-readable form for each definition/use of a variable/sub/format.
168 .ie n .IP """\-d""" 8
169 .el .IP \f(CW\-d\fR 8
170 .IX Item "-d"
171 Don\*(Aqt output the "(definitions)" sections.
172 .ie n .IP """\-D[tO]""" 8
173 .el .IP \f(CW\-D[tO]\fR 8
174 .IX Item "-D[tO]"
175 (Internal) debug options, probably only useful if \f(CW\*(C`\-r\*(C'\fR included.
176 The \f(CW\*(C`t\*(C'\fR option prints the object on the top of the stack as it\*(Aqs
177 being tracked. The \f(CW\*(C`O\*(C'\fR option prints each operator as it\*(Aqs being
178 processed in the execution order of the program.
179 .SH BUGS
180 .IX Header "BUGS"
181 Non\-lexical variables are quite difficult to track through a program.
182 Sometimes the type of a non\-lexical variable\*(Aqs use is impossible to
183 determine. Introductions of non\-lexical non\-scalars don\*(Aqt seem to be
184 reported properly.
185 .SH AUTHOR
186 .IX Header "AUTHOR"
187 Malcolm Beattie, [email protected].