Debian Codegraph @

upstream/debian-unstable/man3/O.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (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 .\"
57 .IX Title "O 3perl"
58 .TH O 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 O \- Generic interface to Perl Compiler backends
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 1
68 \& perl \-MO=[\-q,]Backend[,OPTIONS] foo.pl
69 .Ve
70 .SH DESCRIPTION
71 .IX Header "DESCRIPTION"
72 This is the module that is used as a frontend to the Perl Compiler.
73 .PP
74 If you pass the \f(CW\*(C`\-q\*(C'\fR option to the module, then the STDOUT
75 filehandle will be redirected into the variable \f(CW$O::BEGIN_output\fR
76 during compilation. This has the effect that any output printed
77 to STDOUT by BEGIN blocks or use'd modules will be stored in this
78 variable rather than printed. It's useful with those backends which
79 produce output themselves (\f(CW\*(C`Deparse\*(C'\fR, \f(CW\*(C`Concise\*(C'\fR etc), so that
80 their output is not confused with that generated by the code
81 being compiled.
82 .PP
83 The \f(CW\*(C`\-qq\*(C'\fR option behaves like \f(CW\*(C`\-q\*(C'\fR, except that it also closes
84 STDERR after deparsing has finished. This suppresses the "Syntax OK"
85 message normally produced by perl.
86 .SH CONVENTIONS
87 .IX Header "CONVENTIONS"
88 Most compiler backends use the following conventions: OPTIONS
89 consists of a comma-separated list of words (no white-space).
90 The \f(CW\*(C`\-v\*(C'\fR option usually puts the backend into verbose mode.
91 The \f(CW\*(C`\-ofile\*(C'\fR option generates output to \fBfile\fR instead of
92 stdout. The \f(CW\*(C`\-D\*(C'\fR option followed by various letters turns on
93 various internal debugging flags. See the documentation for the
94 desired backend (named \f(CW\*(C`B::Backend\*(C'\fR for the example above) to
95 find out about that backend.
96 .SH IMPLEMENTATION
97 .IX Header "IMPLEMENTATION"
98 This section is only necessary for those who want to write a
99 compiler backend module that can be used via this module.
100 .PP
101 The command-line mentioned in the SYNOPSIS section corresponds to
102 the Perl code
103 .PP
104 .Vb 1
105 \& use O ("Backend", OPTIONS);
106 .Ve
107 .PP
108 The \f(CW\*(C`O::import\*(C'\fR function loads the appropriate \f(CW\*(C`B::Backend\*(C'\fR module
109 and calls its \f(CW\*(C`compile\*(C'\fR function, passing it OPTIONS. That function
110 is expected to return a sub reference which we'll call CALLBACK. Next,
111 the "compile-only" flag is switched on (equivalent to the command-line
112 option \f(CW\*(C`\-c\*(C'\fR) and a CHECK block is registered which calls
113 CALLBACK. Thus the main Perl program mentioned on the command-line is
114 read in, parsed and compiled into internal syntax tree form. Since the
115 \&\f(CW\*(C`\-c\*(C'\fR flag is set, the program does not start running (excepting BEGIN
116 blocks of course) but the CALLBACK function registered by the compiler
117 backend is called.
118 .PP
119 In summary, a compiler backend module should be called "B::Foo"
120 for some foo and live in the appropriate directory for that name.
121 It should define a function called \f(CW\*(C`compile\*(C'\fR. When the user types
122 .PP
123 .Vb 1
124 \& perl \-MO=Foo,OPTIONS foo.pl
125 .Ve
126 .PP
127 that function is called and is passed those OPTIONS (split on
128 commas). It should return a sub ref to the main compilation function.
129 After the user's program is loaded and parsed, that returned sub ref
130 is invoked which can then go ahead and do the compilation, usually by
131 making use of the \f(CW\*(C`B\*(C'\fR module's functionality.
132 .SH BUGS
133 .IX Header "BUGS"
134 The \f(CW\*(C`\-q\*(C'\fR and \f(CW\*(C`\-qq\*(C'\fR options don't work correctly if perl isn't
135 compiled with PerlIO support : STDOUT will be closed instead of being
136 redirected to \f(CW$O::BEGIN_output\fR.
137 .SH AUTHOR
138 .IX Header "AUTHOR"
139 Malcolm Beattie, \f(CW\*(C`[email protected]\*(C'\fR