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
16       compilation.  This has the effect that any output printed to STDOUT by
17       BEGIN blocks or use'd modules will be stored in this variable rather
18       than printed. It's useful with those backends which produce output
19       themselves ("Deparse", "Concise" etc), so that their output is not
20       confused 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
30       generates output to file instead of stdout. The "-D" option followed by
31       various letters turns on various internal debugging flags. See the
32       documentation for the desired backend (named "B::Backend" for the
33       example 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 "O::import" function loads the appropriate "B::Backend" module and
45       calls its "compile" function, passing it OPTIONS. That function is
46       expected to return a sub reference which we'll call CALLBACK. Next, the
47       "compile-only" flag is switched on (equivalent to the command-line
48       option "-c") and a CHECK block is registered which calls CALLBACK. Thus
49       the main Perl program mentioned on the command-line is read in, parsed
50       and compiled into internal syntax tree form. Since the "-c" flag is
51       set, the program does not start running (excepting BEGIN blocks of
52       course) but the CALLBACK function registered by the compiler backend is
53       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.34.1                      2022-03-15                            O(3pm)
Impressum