1O(3pm)                 Perl Programmers Reference Guide                 O(3pm)
2
3
4

NAME

6       O - Generic interface to Perl Compiler backends
7

SYNOPSIS

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

DESCRIPTION

12       This is the module that is used as a frontend to the Perl Compiler.
13
14       If you pass the "-q" option to the module, then the STDOUT filehandle
15       will be redirected into the variable $O::BEGIN_output during compila‐
16       tion.  This has the effect that any output printed to STDOUT by BEGIN
17       blocks or use'd modules will be stored in this variable rather than
18       printed. It's useful with those backends which produce output them‐
19       selves ("Deparse", "Concise" etc), so that their output is not confused
20       with that generated by the code being compiled.
21
22       The "-qq" option behaves like "-q", except that it also closes STDERR
23       after deparsing has finished. This suppresses the "Syntax OK" message
24       normally produced by perl.
25

CONVENTIONS

27       Most compiler backends use the following conventions: OPTIONS consists
28       of a comma-separated list of words (no white-space).  The "-v" option
29       usually puts the backend into verbose mode.  The "-ofile" option gener‐
30       ates output to file instead of stdout. The "-D" option followed by var‐
31       ious letters turns on various internal debugging flags. See the docu‐
32       mentation for the desired backend (named "B::Backend" for the example
33       above) to find out about that backend.
34

IMPLEMENTATION

36       This section is only necessary for those who want to write a compiler
37       backend module that can be used via this module.
38
39       The command-line mentioned in the SYNOPSIS section corresponds to the
40       Perl code
41
42           use O ("Backend", OPTIONS);
43
44       The "import" function which that calls loads in the appropriate
45       "B::Backend" module and calls the "compile" function in that package,
46       passing it OPTIONS. That function is expected to return a sub reference
47       which we'll call CALLBACK. Next, the "compile-only" flag is switched on
48       (equivalent to the command-line option "-c") and a CHECK block is reg‐
49       istered which calls CALLBACK. Thus the main Perl program mentioned on
50       the command-line is read in, parsed and compiled into internal syntax
51       tree form. Since the "-c" flag is set, the program does not start run‐
52       ning (excepting BEGIN blocks of course) but the CALLBACK function reg‐
53       istered by the compiler backend is called.
54
55       In summary, a compiler backend module should be called "B::Foo" for
56       some foo and live in the appropriate directory for that name.  It
57       should define a function called "compile". When the user types
58
59           perl -MO=Foo,OPTIONS foo.pl
60
61       that function is called and is passed those OPTIONS (split on commas).
62       It should return a sub ref to the main compilation function.  After the
63       user's program is loaded and parsed, that returned sub ref is invoked
64       which can then go ahead and do the compilation, usually by making use
65       of the "B" module's functionality.
66

BUGS

68       The "-q" and "-qq" options don't work correctly if perl isn't compiled
69       with PerlIO support : STDOUT will be closed instead of being redirected
70       to $O::BEGIN_output.
71

AUTHOR

73       Malcolm Beattie, "mbeattie@sable.ox.ac.uk"
74
75
76
77perl v5.8.8                       2001-09-21                            O(3pm)
Impressum