Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / O.html
blob030c700cfbf61a54055124cde6cad4a7324f6eb0
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>O - Generic interface to Perl Compiler backends</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;O - Generic interface to Perl Compiler backends</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#conventions">CONVENTIONS</a></li>
26 <li><a href="#implementation">IMPLEMENTATION</a></li>
27 <li><a href="#bugs">BUGS</a></li>
28 <li><a href="#author">AUTHOR</a></li>
29 </ul>
30 <!-- INDEX END -->
32 <hr />
33 <p>
34 </p>
35 <h1><a name="name">NAME</a></h1>
36 <p>O - Generic interface to Perl Compiler backends</p>
37 <p>
38 </p>
39 <hr />
40 <h1><a name="synopsis">SYNOPSIS</a></h1>
41 <pre>
42 perl -MO=[-q,]Backend[,OPTIONS] foo.pl</pre>
43 <p>
44 </p>
45 <hr />
46 <h1><a name="description">DESCRIPTION</a></h1>
47 <p>This is the module that is used as a frontend to the Perl Compiler.</p>
48 <p>If you pass the <code>-q</code> option to the module, then the STDOUT
49 filehandle will be redirected into the variable <code>$O::BEGIN_output</code>
50 during compilation. This has the effect that any output printed
51 to STDOUT by BEGIN blocks or use'd modules will be stored in this
52 variable rather than printed. It's useful with those backends which
53 produce output themselves (<code>Deparse</code>, <code>Concise</code> etc), so that
54 their output is not confused with that generated by the code
55 being compiled.</p>
56 <p>The <code>-qq</code> option behaves like <code>-q</code>, except that it also closes
57 STDERR after deparsing has finished. This suppresses the ``Syntax OK''
58 message normally produced by perl.</p>
59 <p>
60 </p>
61 <hr />
62 <h1><a name="conventions">CONVENTIONS</a></h1>
63 <p>Most compiler backends use the following conventions: OPTIONS
64 consists of a comma-separated list of words (no white-space).
65 The <code>-v</code> option usually puts the backend into verbose mode.
66 The <code>-ofile</code> option generates output to <strong>file</strong> instead of
67 stdout. The <code>-D</code> option followed by various letters turns on
68 various internal debugging flags. See the documentation for the
69 desired backend (named <code>B::Backend</code> for the example above) to
70 find out about that backend.</p>
71 <p>
72 </p>
73 <hr />
74 <h1><a name="implementation">IMPLEMENTATION</a></h1>
75 <p>This section is only necessary for those who want to write a
76 compiler backend module that can be used via this module.</p>
77 <p>The command-line mentioned in the SYNOPSIS section corresponds to
78 the Perl code</p>
79 <pre>
80 use O (&quot;Backend&quot;, OPTIONS);</pre>
81 <p>The <code>import</code> function which that calls loads in the appropriate
82 <code>B::Backend</code> module and calls the <code>compile</code> function in that
83 package, passing it OPTIONS. That function is expected to return
84 a sub reference which we'll call CALLBACK. Next, the ``compile-only''
85 flag is switched on (equivalent to the command-line option <code>-c</code>)
86 and a CHECK block is registered which calls CALLBACK. Thus the main
87 Perl program mentioned on the command-line is read in, parsed and
88 compiled into internal syntax tree form. Since the <code>-c</code> flag is
89 set, the program does not start running (excepting BEGIN blocks of
90 course) but the CALLBACK function registered by the compiler
91 backend is called.</p>
92 <p>In summary, a compiler backend module should be called ``B::Foo''
93 for some foo and live in the appropriate directory for that name.
94 It should define a function called <code>compile</code>. When the user types</p>
95 <pre>
96 perl -MO=Foo,OPTIONS foo.pl</pre>
97 <p>that function is called and is passed those OPTIONS (split on
98 commas). It should return a sub ref to the main compilation function.
99 After the user's program is loaded and parsed, that returned sub ref
100 is invoked which can then go ahead and do the compilation, usually by
101 making use of the <code>B</code> module's functionality.</p>
103 </p>
104 <hr />
105 <h1><a name="bugs">BUGS</a></h1>
106 <p>The <code>-q</code> and <code>-qq</code> options don't work correctly if perl isn't
107 compiled with PerlIO support : STDOUT will be closed instead of being
108 redirected to <code>$O::BEGIN_output</code>.</p>
110 </p>
111 <hr />
112 <h1><a name="author">AUTHOR</a></h1>
113 <p>Malcolm Beattie, <code>mbeattie@sable.ox.ac.uk</code></p>
114 <table border="0" width="100%" cellspacing="0" cellpadding="3">
115 <tr><td class="block" style="background-color: #cccccc" valign="middle">
116 <big><strong><span class="block">&nbsp;O - Generic interface to Perl Compiler backends</span></strong></big>
117 </td></tr>
118 </table>
120 </body>
122 </html>