{
    "content": [
        {
            "type": "text",
            "text": "# O (perldoc)\n\n## NAME\n\nO - Generic interface to Perl Compiler backends\n\n## SYNOPSIS\n\nperl -MO=[-q,]Backend[,OPTIONS] foo.pl\n\n## DESCRIPTION\n\nThis is the module that is used as a frontend to the Perl Compiler.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **CONVENTIONS**\n- **IMPLEMENTATION**\n- **BUGS**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "O",
        "section": "",
        "mode": "perldoc",
        "summary": "O - Generic interface to Perl Compiler backends",
        "synopsis": "perl -MO=[-q,]Backend[,OPTIONS] foo.pl",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "CONVENTIONS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "IMPLEMENTATION",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "O - Generic interface to Perl Compiler backends\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "perl -MO=[-q,]Backend[,OPTIONS] foo.pl\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is the module that is used as a frontend to the Perl Compiler.\n\nIf you pass the \"-q\" option to the module, then the STDOUT filehandle will be redirected into\nthe variable $O::BEGINoutput during compilation. This has the effect that any output printed to\nSTDOUT by BEGIN blocks or use'd modules will be stored in this variable rather than printed.\nIt's useful with those backends which produce output themselves (\"Deparse\", \"Concise\" etc), so\nthat their output is not confused with that generated by the code being compiled.\n\nThe \"-qq\" option behaves like \"-q\", except that it also closes STDERR after deparsing has\nfinished. This suppresses the \"Syntax OK\" message normally produced by perl.\n",
                "subsections": []
            },
            "CONVENTIONS": {
                "content": "Most compiler backends use the following conventions: OPTIONS consists of a comma-separated list\nof words (no white-space). The \"-v\" option usually puts the backend into verbose mode. The\n\"-ofile\" option generates output to file instead of stdout. The \"-D\" option followed by various\nletters turns on various internal debugging flags. See the documentation for the desired backend\n(named \"B::Backend\" for the example above) to find out about that backend.\n",
                "subsections": []
            },
            "IMPLEMENTATION": {
                "content": "This section is only necessary for those who want to write a compiler backend module that can be\nused via this module.\n\nThe command-line mentioned in the SYNOPSIS section corresponds to the Perl code\n\nuse O (\"Backend\", OPTIONS);\n\nThe \"O::import\" function loads the appropriate \"B::Backend\" module and calls its \"compile\"\nfunction, passing it OPTIONS. That function is expected to return a sub reference which we'll\ncall CALLBACK. Next, the \"compile-only\" flag is switched on (equivalent to the command-line\noption \"-c\") and a CHECK block is registered which calls CALLBACK. Thus the main Perl program\nmentioned on the command-line is read in, parsed and compiled into internal syntax tree form.\nSince the \"-c\" flag is set, the program does not start running (excepting BEGIN blocks of\ncourse) but the CALLBACK function registered by the compiler backend is called.\n\nIn summary, a compiler backend module should be called \"B::Foo\" for some foo and live in the\nappropriate directory for that name. It should define a function called \"compile\". When the user\ntypes\n\nperl -MO=Foo,OPTIONS foo.pl\n\nthat function is called and is passed those OPTIONS (split on commas). It should return a sub\nref to the main compilation function. After the user's program is loaded and parsed, that\nreturned sub ref is invoked which can then go ahead and do the compilation, usually by making\nuse of the \"B\" module's functionality.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "The \"-q\" and \"-qq\" options don't work correctly if perl isn't compiled with PerlIO support :\nSTDOUT will be closed instead of being redirected to $O::BEGINoutput.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Malcolm Beattie, \"mbeattie@sable.ox.ac.uk\"\n",
                "subsections": []
            }
        }
    }
}