{
    "content": [
        {
            "type": "text",
            "text": "# Inline (man)\n\n## NAME\n\nInline - Write Perl Subroutines in Other Programming Languages\n\n## SYNOPSIS\n\nuse Inline C;\nprint \"9 + 16 = \", add(9, 16), \"\\n\";\nprint \"9 - 16 = \", subtract(9, 16), \"\\n\";\nEND\nC\nint add(int x, int y) {\nreturn x + y;\n}\nint subtract(int x, int y) {\nreturn x - y;\n}\n\n## DESCRIPTION\n\nThe Inline module allows you to put source code from other programming languages directly\n\"inline\" in a Perl script or module. The code is automatically compiled as needed, and then\nloaded for immediate access from Perl.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION** (11 subsections)\n- **CONFIGURATION OPTIONS**\n- **INLINE CONFIGURATION SHORTCUTS**\n- **WRITING MODULES WITH INLINE**\n- **HOW INLINE WORKS**\n- **SEE ALSO**\n- **BUGS AND DEFICIENCIES**\n- **AUTHOR**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Inline",
        "section": "",
        "mode": "man",
        "summary": "Inline - Write Perl Subroutines in Other Programming Languages",
        "synopsis": "use Inline C;\nprint \"9 + 16 = \", add(9, 16), \"\\n\";\nprint \"9 - 16 = \", subtract(9, 16), \"\\n\";\nEND\nC\nint add(int x, int y) {\nreturn x + y;\n}\nint subtract(int x, int y) {\nreturn x - y;\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 18,
                "subsections": [
                    {
                        "name": "Why Inline?",
                        "lines": 67
                    },
                    {
                        "name": "USING THE INLINE.PM MODULE",
                        "lines": 8
                    },
                    {
                        "name": "The Basics",
                        "lines": 153
                    },
                    {
                        "name": "More about the DATA Section",
                        "lines": 46
                    },
                    {
                        "name": "Configuration Options",
                        "lines": 67
                    },
                    {
                        "name": "On and Off",
                        "lines": 13
                    },
                    {
                        "name": "Playing 'with' Others",
                        "lines": 32
                    },
                    {
                        "name": "Inline Shortcuts",
                        "lines": 21
                    },
                    {
                        "name": "The Inline 'directory'",
                        "lines": 20
                    },
                    {
                        "name": "Debugging Inline Errors",
                        "lines": 14
                    },
                    {
                        "name": "The 'config' Registry File",
                        "lines": 9
                    }
                ]
            },
            {
                "name": "CONFIGURATION OPTIONS",
                "lines": 149,
                "subsections": []
            },
            {
                "name": "INLINE CONFIGURATION SHORTCUTS",
                "lines": 81,
                "subsections": []
            },
            {
                "name": "WRITING MODULES WITH INLINE",
                "lines": 115,
                "subsections": []
            },
            {
                "name": "HOW INLINE WORKS",
                "lines": 122,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "BUGS AND DEFICIENCIES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 12,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Inline - Write Perl Subroutines in Other Programming Languages\n",
                "subsections": []
            },
            "VERSION": {
                "content": "This document describes Inline version 0.86.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Inline C;\n\nprint \"9 + 16 = \", add(9, 16), \"\\n\";\nprint \"9 - 16 = \", subtract(9, 16), \"\\n\";\n\nEND\nC\nint add(int x, int y) {\nreturn x + y;\n}\n\nint subtract(int x, int y) {\nreturn x - y;\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The Inline module allows you to put source code from other programming languages directly\n\"inline\" in a Perl script or module. The code is automatically compiled as needed, and then\nloaded for immediate access from Perl.\n\nInline saves you from the hassle of having to write and compile your own glue code using\nfacilities like XS or SWIG. Simply type the code where you want it and run your Perl as\nnormal. All the hairy details are handled for you. The compilation and installation of your\ncode chunks all happen transparently; all you will notice is the delay of compilation on the\nfirst run.\n\nThe Inline code only gets compiled the first time you run it (or whenever it is modified) so\nyou only take the performance hit once. Code that is Inlined into distributed modules (like\non the CPAN) will get compiled when the module is installed, so the end user will never\nnotice the compilation time.\n\nBest of all, it works the same on both Unix and Microsoft Windows. See Inline- Support for\nsupport information.\n",
                "subsections": [
                    {
                        "name": "Why Inline?",
                        "content": "Do you want to know \"Why would I use other languages in Perl?\" or \"Why should I use Inline to\ndo it?\"? I'll try to answer both.\n\nWhy would I use other languages in Perl?\nThe most obvious reason is performance. For an interpreted language, Perl is very fast.\nMany people will say \"Anything Perl can do, C can do faster\". (They never mention the\ndevelopment time :-) Anyway, you may be able to remove a bottleneck in your Perl code by\nusing another language, without having to write the entire program in that language. This\nkeeps your overall development time down, because you're using Perl for all of the non-\ncritical code.\n\nAnother reason is to access functionality from existing API-s that use the language. Some\nof this code may only be available in binary form. But by creating small subroutines in\nthe native language, you can \"glue\" existing libraries to your Perl. As a user of the\nCPAN, you know that code reuse is a good thing. So why throw away those Fortran libraries\njust yet?\n\nIf you are using Inline with the C language, then you can access the full internals of\nPerl itself. This opens up the floodgates to both extreme power and peril.\n\nMaybe the best reason is \"Because you want to!\". Diversity keeps the world interesting.\nTMTOWTDI!\n\nWhy should I use Inline to do it?\nThere are already two major facilities for extending Perl with C. They are XS and SWIG.\nBoth are similar in their capabilities, at least as far as Perl is concerned. And both of\nthem are quite difficult to learn compared to Inline.\n\nThere is a big fat learning curve involved with setting up and using the XS environment.\nYou need to get quite intimate with the following docs:\n\n•   perlxs\n\n•   perlxstut\n\n•   perlapi\n\n•   perlguts\n\n•   perlmod\n\n•   h2xs\n\n•   xsubpp\n\n•   ExtUtils::MakeMaker\n\nWith Inline you can be up and running in minutes. There is a C Cookbook with lots of\nshort but complete programs that you can extend to your real-life problems. No need to\nlearn about the complicated build process going on in the background. You don't even need\nto compile the code yourself. Inline takes care of every last detail except writing the C\ncode.\n\nPerl programmers cannot be bothered with silly things like compiling. \"Tweak, Run, Tweak,\nRun\" is our way of life. Inline does all the dirty work for you.\n\nAnother advantage of Inline is that you can use it directly in a script. You can even use\nit in a Perl one-liner. With XS and SWIG, you always set up an entirely separate module.\nEven if you only have one or two functions. Inline makes easy things easy, and hard\nthings possible. Just like Perl.\n\nFinally, Inline supports several programming languages (not just C and C++). As of this\nwriting, Inline has support for C, C++, Java, Python, Ruby, Tcl, Assembler, Basic, Guile,\nBefunge, Octave, Awk, BC, TT (Template Toolkit), WebChat and even PERL. New Inline\nLanguage Support Modules (ILSMs) are regularly being added. See Inline-API for details on\nhow to create your own ILSM.\n"
                    },
                    {
                        "name": "USING THE INLINE.PM MODULE",
                        "content": "Inline is a little bit different than most of the Perl modules that you are used to. It\ndoesn't import any functions into your namespace and it doesn't have any object oriented\nmethods. Its entire interface (with two minor exceptions) is specified through the 'use\nInline ...' command.\n\nThis section will explain all of the different ways to \"use Inline\". If you want to begin\nusing C with Inline immediately, see Inline::C-Cookbook.\n"
                    },
                    {
                        "name": "The Basics",
                        "content": "The most basic form for using Inline is:\n\nuse Inline X => \"X source code\";\n\nwhere 'X' is one of the supported Inline programming languages. The second parameter\nidentifies the source code that you want to bind to Perl. The source code can be specified\nusing any of the following syntaxes:\n\nThe DATA Keyword.\nuse Inline Java => 'DATA';\n\n# Perl code goes here ...\n\nDATA\nJava\n/* Java code goes here ... */\n\nThe easiest and most visually clean way to specify your source code in an Inline Perl\nprogram is to use the special \"DATA\" keyword. This tells Inline to look for a special\nmarker in your \"DATA\" filehandle's input stream. In this example the special marker is\n\"Java\", which is the programming language surrounded by double underscores.\n\nIn case you've forgotten, the \"DATA\" pseudo file is comprised of all the text after the\n\"END\" or \"DATA\" section of your program. If you're working outside the \"main\"\npackage, you'd best use the \"DATA\" marker or else Inline will not find your code.\n\nUsing this scheme keeps your Perl code at the top, and all the ugly Java stuff down below\nwhere it belongs. This is visually clean and makes for more maintainable code. An\nexcellent side benefit is that you don't have to escape any characters like you might in\na Perl string. The source code is verbatim.  For these reasons, I prefer this method the\nmost.\n\nThe only problem with this style is that since Perl can't read the \"DATA\" filehandle\nuntil runtime, it obviously can't bind your functions until runtime. The net effect of\nthis is that you can't use your Inline functions as barewords (without predeclaring them)\nbecause Perl has no idea they exist during compile time.\n\nThe FILE and BELOW keywords.\nuse Inline::Files;\nuse Inline Java => 'file';\n\n# Perl code goes here ...\n\nJAVA\n/* Java code goes here ... */\n\nThis is the newest method of specifying your source code. It makes use of the Perl module\n\"Inline::Files\" written by Damian Conway. The basic style and meaning are the same as for\nthe \"DATA\" keyword, but there are a few syntactic and semantic twists.\n\nFirst, you must say 'use Inline::Files' before you 'use Inline' code that needs those\nfiles. The special '\"DATA\"' keyword is replaced by either '\"file\"' or '\"below\"'. This\nallows for the bad pun idiom of:\n\nuse Inline C => 'below';\n\nYou can omit the \"DATA\" tag now. Inline::Files is a source filter that will remove\nthese sections from your program before Perl compiles it. They are then available for\nInline to make use of. And since this can all be done at compile time, you don't have to\nworry about the caveats of the 'DATA' keyword.\n\nThis module has a couple small gotchas. Since Inline::Files only recognizes file markers\nwith capital letters, you must specify the capital form of your language name. Also,\nthere is a startup time penalty for using a source code filter.\n\nAt this point Inline::Files is alpha software and use of it is experimental.  Inline's\nintegration of this module is also fledgling at the time being. One of things I plan to\ndo with Inline::Files is to get line number info so when an extension doesn't compile,\nthe error messages will point to the correct source file and line number.\n\nMy best advice is to use Inline::Files for testing (especially as support for it\nimproves), but use DATA for production and distributed/CPAN code.\n\nStrings\nuse Inline Java => <<'END';\n\n/* Java code goes here ... */\nEND\n\n# Perl code goes here ...\n\nYou also just specify the source code as a single string. A handy way to write the string\nis to use Perl's \"here document\" style of quoting. This is ok for small functions but can\nget unwieldy in the large. On the other hand, the string variant probably has the least\nstartup penalty and all functions are bound at compile time.\n\nIf you wish to put the string into a scalar variable, please be aware that the \"use\"\nstatement is a compile time directive. As such, all the variables it uses must also be\nset at compile time, \"before\" the 'use Inline' statement.  Here is one way to do it:\n\nmy $code;\nBEGIN {\n$code = <<END;\n\n/* Java code goes here ... */\nEND\n}\nuse Inline Java => $code;\n\n# Perl code goes here ...\n\nThe bind() Function\nAn alternative to using the BEGIN block method is to specify the source code at run time\nusing the 'Inline->bind()' method. (This is one of the interface exceptions mentioned\nabove) The \"bind()\" method takes the same arguments as 'use Inline ...'.\n\nmy $code = <<END;\n\n/* Java code goes here ... */\nEND\n\nInline->bind(Java => $code);\n\nYou can think of \"bind()\" as a way to \"eval()\" code in other programming languages.\n\nAlthough bind() is a powerful feature, it is not recommended for use in Inline based\nmodules. In fact, it won't work at all for installable modules. See instructions below\nfor creating modules with Inline.\n\nOther Methods\nThe source code for Inline can also be specified as an external filename, a reference to\na subroutine that returns source code, or a reference to an array that contains lines of\nsource code. (Note that if the external source file is in the current directory it must\nbe specified with a leading '.' - ie '.file.ext' instead of simply 'file.ext'.) These\nmethods are less frequently used but may be useful in some situations.\n\nFor instance, to load your C++ code from a file named the same as your perl module with a\nswapped file extension, you can use:\n\nuse Inline CPP => (FILE =~ s/\\.pm$/.cpp/r);\n\nShorthand\nIf you are using the 'DATA' or 'file' methods described above and there are no extra\nparameters, you can omit the keyword altogether. For example:\n\nuse Inline 'Java';\n\n# Perl code goes here ...\n\nDATA\nJava\n/* Java code goes here ... */\n\nor\n\nuse Inline::Files;\nuse Inline 'Java';\n\n# Perl code goes here ...\n\nJAVA\n/* Java code goes here ... */\n"
                    },
                    {
                        "name": "More about the DATA Section",
                        "content": "If you are writing a module, you can also use the DATA section for POD and AutoLoader\nsubroutines. Just be sure to put them before the first Inline marker. If you install the\nhelper module \"Inline::Filters\", you can even use POD inside your Inline code. You just have\nto specify a filter to strip it out.\n\nYou can also specify multiple Inline sections, possibly in different programming languages.\nHere is another example:\n\n# The module Foo.pm\npackage Foo;\nuse AutoLoader;\n\nuse Inline C;\nuse Inline C => DATA => filters => 'StripPOD';\nuse Inline Python;\n\n1;\n\nDATA\n\nsub marine {\n# This is an autoloaded subroutine\n}\n\n=head1 External subroutines\n\n=cut\n\nC\n/* First C section */\n\nC\n/* Second C section */\n=head1 My C Function\n\nSome POD doc.\n\n=cut\n\nPython\n\"\"\"A Python Section\"\"\"\n\nAn important thing to remember is that you need to have one \"use Inline Foo => 'DATA'\" for\neach \"Foo\" marker, and they must be in the same order.  This allows you to apply\ndifferent configuration options to each section.\n"
                    },
                    {
                        "name": "Configuration Options",
                        "content": "Inline tries to do the right thing as often as possible. But sometimes you may need to\noverride the default actions. This is easy to do. Simply list the Inline configuration\noptions after the regular Inline parameters. All configuration options are specified as (key,\nvalue) pairs.\n\nuse Inline (C => 'DATA',\ndirectory => './inlinedir',\nlibs => '-lfoo',\ninc => '-I/foo/include',\nprefix => 'XXX',\nwarnings => 0,\n);\n\nYou can also specify the configuration options on a separate Inline call like this:\n\nuse Inline (C => Config =>\ndirectory => './inlinedir',\nlibs => '-lfoo',\ninc => '-I/foo/include',\nprefix => 'XXX',\nwarnings => 0,\n);\nuse Inline C => <<'ENDOFCCODE';\n\nThe special keyword 'Config' tells Inline that this is a configuration-only call. No source\ncode will be compiled or bound to Perl.\n\nIf you want to specify global configuration options that don't apply to a particular\nlanguage, just leave the language out of the call. Like this:\n\nuse Inline Config => warnings => 0;\n\nThe Config options are inherited and additive. You can use as many Config calls as you want.\nAnd you can apply different options to different code sections. When a source code section is\npassed in, Inline will apply whichever options have been specified up to that point. Here is\na complex configuration example:\n\nuse Inline (Config =>\ndirectory => './inlinedir',\n);\nuse Inline (C => Config =>\nlibs => '-lglobal',\n);\nuse Inline (C => 'DATA',         # First C Section\nlibs => ['-llocal1', '-llocal2'],\n);\nuse Inline (Config =>\nwarnings => 0,\n);\nuse Inline (Python => 'DATA',    # First Python Section\nlibs => '-lmypython1',\n);\nuse Inline (C => 'DATA',         # Second C Section\nlibs => [undef, '-llocal3'],\n);\n\nThe first \"Config\" applies to all subsequent calls. The second \"Config\" applies to all\nsubsequent \"C\" sections (but not \"Python\" sections). In the first \"C\" section, the external\nlibraries \"global\", \"local1\" and \"local2\" are used. (Most options allow either string or\narray ref forms, and do the right thing.) The \"Python\" section does not use the \"global\"\nlibrary, but does use the same \"DIRECTORY\", and has warnings turned off. The second \"C\"\nsection only uses the \"local3\" library. That's because a value of \"undef\" resets the additive\nbehavior.\n\nThe \"directory\" and \"warnings\" options are generic Inline options. All other options are\nlanguage specific. To find out what the \"C\" options do, see \"Inline::C\".\n"
                    },
                    {
                        "name": "On and Off",
                        "content": "If a particular config option has value options of 1 and 0, you can use the 'enable' and\n'disable' modifiers. In other words, this:\n\nuse Inline Config =>\nforcebuild => 1,\ncleanafterbuild => 0;\n\ncould be reworded as:\n\nuse Inline Config =>\nenable => forcebuild =>\ndisable => cleanafterbuild;\n"
                    },
                    {
                        "name": "Playing 'with' Others",
                        "content": "Inline has a special configuration syntax that tells it to get more configuration options\nfrom other Perl modules. Here is an example:\n\nuse Inline with => 'Event';\n\nThis tells Inline to load the module \"Event.pm\" and ask it for configuration information.\nSince \"Event\" has a C API of its own, it can pass Inline all of the information it needs to\nbe able to use \"Event\" C callbacks seamlessly.\n\nThat means that you don't need to specify the typemaps, shared libraries, include files and\nother information required to get this to work.\n\nYou can specify a single module or a list of them. Like:\n\nuse Inline with => qw(Event Foo Bar);\n\nCurrently, modules that works with Inline include \"Event\", \"PDL\", and those that use\n\"Alien::Build\".\n\nIn order to make your module work with Inline in this way, your module needs to provide a\nclass method called \"Inline\" that takes an Inline language as a parameter (e.g. \"C\"), and\nreturns a reference to a hash with configuration information that is acceptable to the\nrelevant ILSM. For C, see C Configuration Options. E.g.:\n\nmy $confighashref = Event->Inline('C'); # only supports C in 1.21\n# hashref contains keys INC, TYPEMAPS, MYEXTLIB, AUTOINCLUDE, BOOT\n\nIf your module uses ExtUtils::Depends version 0.400 or higher, your module only needs this:\n\npackage Module;\nuse autouse Module::Install::Files => qw(Inline);\n"
                    },
                    {
                        "name": "Inline Shortcuts",
                        "content": "Inline lets you set many configuration options from the command line. These options are\ncalled 'shortcuts'. They can be very handy, especially when you only want to set the options\ntemporarily, for say, debugging.\n\nFor instance, to get some general information about your Inline code in the script \"Foo.pl\",\nuse the command:\n\nperl -MInline=info Foo.pl\n\nIf you want to force your code to compile, even if its already done, use:\n\nperl -MInline=force Foo.pl\n\nIf you want to do both, use:\n\nperl -MInline=info -MInline=force Foo.pl\n\nor better yet:\n\nperl -MInline=info,force Foo.pl\n"
                    },
                    {
                        "name": "The Inline 'directory'",
                        "content": "Inline needs a place to build your code and to install the results of the build. It uses a\nsingle directory named '.Inline/' under normal circumstances. If you create this directory in\nyour home directory, the current directory or in the directory where your program resides,\nInline will find and use it. You can also specify it in the environment variable\n\"PERLINLINEDIRECTORY\" or directly in your program, by using the \"directory\" keyword option.\nIf Inline cannot find the directory in any of these places it will create a 'Inline/'\ndirectory in either your current directory or the directory where your script resides.\n\nOne of the key factors to using Inline successfully, is understanding this directory. When\ndeveloping code it is usually best to create this directory (or let Inline do it) in your\ncurrent directory. Remember that there is nothing sacred about this directory except that it\nholds your compiled code.  Feel free to delete it at any time. Inline will simply start from\nscratch and recompile your code on the next run. If you have several programs that you want\nto force to recompile, just delete your '.Inline/' directory.\n\nIt is probably best to have a separate '.Inline/' directory for each project that you are\nworking on. You may want to keep stable code in the <.Inline/> in your home directory. On\nmulti-user systems, each user should have their own '.Inline/' directories. It could be a\nsecurity risk to put the directory in a shared place like \"/tmp/\".\n"
                    },
                    {
                        "name": "Debugging Inline Errors",
                        "content": "All programmers make mistakes. When you make a mistake with Inline, like writing bad C code,\nyou'll get a big error report on your screen. This report tells you where to look to do the\ndebugging. Some languages may also dump out the error messages generated from the build.\n\nWhen Inline needs to build something it creates a subdirectory under your \"DIRECTORY/build/\"\ndirectory. This is where it writes all the components it needs to build your extension.\nThings like XS files, Makefiles and output log files.\n\nIf everything goes OK, Inline will delete this subdirectory. If there is an error, Inline\nwill leave the directory intact and print its location.  The idea is that you are supposed to\ngo into that directory and figure out what happened.\n\nRead the doc for your particular Inline Language Support Module for more information.\n"
                    },
                    {
                        "name": "The 'config' Registry File",
                        "content": "Inline keeps a cached file of all of the Inline Language Support Module's meta data in a file\ncalled \"config\". This file can be found in your \"directory\" directory. If the file does not\nexist, Inline creates a new one. It will search your system for any module beginning with\n\"Inline::\". It will then call that module's \"register()\" method to get useful information for\nfuture invocations.\n\nWhenever you add a new ILSM, you should delete this file so that Inline will auto-discover\nyour newly installed language module. (This should no longer be necessary as of Inline-0.49.)\n"
                    }
                ]
            },
            "CONFIGURATION OPTIONS": {
                "content": "This section lists all of the generic Inline configuration options. For language specific\nconfiguration, see the doc for that language.\n\n\"directory\"\nThe \"directory\" config option is the directory that Inline uses to both build and install\nan extension.\n\nNormally Inline will search in a bunch of known places for a directory called '.Inline/'.\nFailing that, it will create a directory called 'Inline/'\n\nIf you want to specify your own directory, use this configuration option.\n\nNote that you must create the \"directory\" directory yourself. Inline will not do it for\nyou.\n\n\"name\"\nYou can use this option to set the name of your Inline extension object module. For\nexample:\n\nuse Inline C => 'DATA',\nname => 'Foo::Bar';\n\nwould cause your C code to be compiled in to the object:\n\nlib/auto/Foo/Bar/Bar.so\nlib/auto/Foo/Bar/Bar.inl\n\n(The .inl component contains dependency information to make sure the source code is in\nsync with the executable)\n\nIf you don't use \"name\", Inline will pick a name for you based on your program name or\npackage name. In this case, Inline will also enable the \"autoname\" option which mangles\nin a small piece of the MD5 fingerprint into your object name, to make it unique.\n\n\"autoname\"\nThis option is enabled whenever the \"name\" parameter is not specified. To disable it say:\n\nuse Inline C => 'DATA',\ndisable => 'autoname';\n\n\"autoname\" mangles in enough of the MD5 fingerprint to make your module name unique.\nObjects created with \"autoname\" will never get replaced. That also means they will never\nget cleaned up automatically.\n\n\"autoname\" is very useful for small throw away scripts. For more serious things, always\nuse the \"name\" option.\n\n\"version\"\nSpecifies the version number of the Inline extension object. It is used only for modules,\nand it must match the global variable $VERSION.  Additionally, this option should used if\n(and only if) a module is being set up to be installed permanently into the Perl sitelib\ntree using Inline::MakeMaker (NOT used by Inline::Module). Inline will croak if you use\nit otherwise.\n\nThe presence of the \"version\" parameter is the official way to let Inline know that your\ncode is an installable/installed module. Inline will never generate an object in the\ntemporary cache (\"Inline/\" directory) if \"version\" is set. It will also never try to\nrecompile a module that was installed into someone's Perl site tree.\n\nSo the basic rule is develop without \"version\", and deliver with \"version\".\n\n\"with\"\n\"with\" can also be used as a configuration option instead of using the special 'with'\nsyntax. Do this if you want to use different sections of Inline code with different\nmodules. (Probably a very rare usage)\n\nuse Event;\nuse Inline C => DATA => with => 'Event';\n\nModules specified using the config form of \"with\" will not be automatically required. You\nmust \"use\" them yourself.\n\n\"using\"\nYou can override modules that get used by ILSMs with the \"using\" option. This is\ntypically used to override the default parser for Inline::C, but might be used by any\nILSM for any purpose.\n\nuse Inline config => using => '::Parser::RecDescent';\nuse Inline C => '...';\n\nThis would tell Inline::C to use Inline::C::Parser::RecDescent.\n\n\"globalload\"\nThis option is for compiled languages only. It tells Inline to tell DynaLoader to load an\nobject file in such a way that its symbols can be dynamically resolved by other object\nfiles. May not work on all platforms. See the \"global\" shortcut below.\n\n\"untaint\"\nYou can use this option whenever you use Perl's \"-T\" switch, for taint checking. This\noption tells Inline to blindly untaint all tainted variables.  (This is generally\nconsidered to be an appallingly insecure thing to do, and not to be recommended - but the\noption is there for you to use if you want.  Please consider using something other than\nInline for scripts that need taint checking.) It also turns on \"safemode\" by default. See\nthe \"untaint\" shortcut below. You will see warnings about blindly untainting fields in\nboth %ENV and Inline objects. If you want to silence these warnings, set the Config\noption \"nountaintwarn\" => 1. There can be some problems untainting Inline scripts where\nolder versions of Cwd, such as those that shipped with early versions of perl-5.8 (and\nearlier), are installed. Updating Cwd will probably solve these problems.\n\nsafemode\nPerform extra safety checking, in an attempt to thwart malicious code. This option cannot\nguarantee security, but it does turn on all the currently implemented checks. (Currently,\nthe only \"currently implemented check\" is to ensure that the \"directory\" option has also\nbeen used.)\n\nThere is a slight startup penalty by using \"safemode\". Also, using \"untaint\"\nautomatically turns this option on. If you need your code to start faster under \"-T\"\n(taint) checking, you'll need to turn this option off manually.  Only do this if you are\nnot worried about security risks. See the \"unsafe\" shortcut below.\n\n\"forcebuild\"\nMakes Inline build (compile) the source code every time the program is run.  The default\nis 0. See the \"force\" shortcut below.\n\n\"buildnoisy\"\nTells ILSMs that they should dump build messages to the terminal rather than be silent\nabout all the build details.\n\n\"buildtimers\"\nTells ILSMs to print timing information about how long each build phase took.  Usually\nrequires \"Time::HiRes\".\n\n\"cleanafterbuild\"\nTells Inline to clean up the current build area if the build was successful.  Sometimes\nyou want to \"disable\" this for debugging. Default is 1. See the \"noclean\" shortcut below.\n\n\"cleanbuildarea\"\nTells Inline to clean up the old build areas within the entire Inline \"directory\".\nDefault is 0. See the \"clean\" shortcut below.\n\n\"printinfo\"\nTells Inline to print various information about the source code. Default is 0.  See the\n\"info\" shortcut below.\n\n\"printversion\"\nTells Inline to print version info about itself. Default is 0. See the \"version\" shortcut\nbelow.\n\n\"reportbug\"\nPuts Inline into 'reportbug' mode, which is what you want if you desire to report a bug.\n\n\"rewriteconfigfile\"\nDefault is 0, but setting \"rewriteconfigfile => 1\" will mean that the existing\nconfiguration file in the Inline \"directory\" will be overwritten.  (This is useful if the\nexisting config file is not up to date as regards supported languages.)\n\n\"warnings\"\nThis option tells Inline whether to print certain warnings. Default is 1.\n",
                "subsections": []
            },
            "INLINE CONFIGURATION SHORTCUTS": {
                "content": "This is a list of all the shortcut configuration options currently available for Inline.\nSpecify them from the command line when running Inline scripts.\n\nperl -MInline=noclean inlinescript.pl\n\nor\n\nperl -MInline=info,force,noclean inlinescript.pl\n\nYou can specify multiple shortcuts separated by commas. They are not case sensitive. You can\nalso specify shortcuts inside the Inline program like this:\n\nuse Inline 'info', 'force', 'noclean';\n\nNOTE: If a 'use Inline' statement is used to set shortcuts, it can not be\nused for additional purposes.\n\n\"clean\"\nTells Inline to remove any build directories that may be lying around in your build area.\nNormally these directories get removed immediately after a successful build. Exceptions\nare when the build fails, or when you use the \"noclean\" or \"reportbug\" options.\n\n\"force\"\nForces the code to be recompiled, even if everything is up to date.\n\n\"global\"\nTurns on the \"globalload\" option.\n\n\"info\"\nThis is a very useful option when you want to know what's going on under the hood. It\ntells Inline to print helpful information to \"STDERR\". Among the things that get printed\nis a list of which Inline functions were successfully bound to Perl.\n\n\"noclean\"\nTells Inline to leave the build files after compiling.\n\n\"noisy\"\nUse the \"buildnoisy\" option to print messages during a build.\n\n\"reportbug\"\nPuts Inline into \"reportbug\" mode, which does special processing when you want to report\na bug. \"reportbug\" also automatically forces a build, and doesn't clean up afterwards.\nThis is so that you can tar and mail the build directory to me. \"reportbug\" will print\nexact instructions on what to do.  Please read and follow them carefully.\n\nNOTE: \"reportbug\" informs you to use the tar command. If your system does not\nhave tar, please use the equivalent \"zip\" command.\n\n\"safe\"\nTurns \"safemode\" on. \"untaint\" will turn this on automatically. While this mode performs\nextra security checking, it does not guarantee safety.\n\n\"siteinstall\"\nThis parameter used to be used for creating installable Inline modules. It has been\nremoved from Inline altogether and replaced with a much simpler and more powerful\nmechanism, \"Inline::MakeMaker\". See the section below on how to create modules with\nInline.\n\n\"testing\"\nUsed internally by Ct09parser.t and Ct10callback.t(in the Inline::C test suite). Setting\nthis option with Inline::C will mean that files named \"parserid\" and \"voidtest\" are\ncreated in the \"./Inlinetest\" directory, creating that directory if it doesn't already\nexist. The files (but not the \"./Inlinetest directory\") are cleaned up by calling\n\"Inline::C::testingcleanup()\". Also used by \"t/06rewriteconfig.t\" to trigger a\nwarning.\n\n\"timers\"\nTurn on \"buildtimers\" to get extra diagnostic info about builds.\n\n\"unsafe\"\nTurns \"safemode\" off. Use this in combination with \"untaint\" for slightly faster startup\ntime under \"-T\". Only use this if you are sure the environment is safe.\n\n\"untaint\"\nTurn the \"untaint\" option on. Used with \"-T\" switch. In terms of secure practices, this\nis definitely not a recommended way of dealing with taint checking, but it's the only\noption currently available with Inline. Use it at your own risk.\n\n\"version\"\nTells Inline to report its release version.\n",
                "subsections": []
            },
            "WRITING MODULES WITH INLINE": {
                "content": "The current preferred way to author CPAN modules with Inline is to use Inline::Module\n(distributed separately). Inline ships with Inline::MakeMaker, which helps you set up a\nMakefile.PL that invokes Inline at install time to compile all the code before it gets\ninstalled, but the resulting module still depends on Inline and the language support module\nlike Inline::C. In order to avoid this dependency, what you really want to do is convert your\ndistribution to plain XS before uploading it to CPAN. Inline::Module fills that role, and\nalso integrates well with more modern authoring tools.\n\nSee Inline::Module for details on that approach, or continue reading below for the older\nInline::MakeMaker technique.\n\nLet's say that you wanted to write a module called \"Math::Simple\". Start by using the\nfollowing command:\n\nh2xs -PAXn Math::Simple\n\nThis will generate a bunch of files that form a skeleton of what you need for a distributable\nmodule. (Read the h2xs manpage to find out what the options do) Next, modify the \"Simple.pm\"\nfile to look like this:\n\npackage Math::Simple;\n$VERSION = '1.23';\n\nuse base 'Exporter';\n@EXPORTOK = qw(add subtract);\nuse strict;\n\nuse Inline C => 'DATA',\nversion => '1.23',\nname => 'Math::Simple';\n\n# The following Inline->init() call is optional - see below for more info.\n#Inline->init();\n\n1;\n\nDATA\n\n=pod\n\n=cut\n\nC\nint add(int x, int y) {\nreturn x + y;\n}\n\nint subtract(int x, int y) {\nreturn x - y;\n}\n\nThe important things to note here are that you must specify a \"name\" and \"version\" parameter.\nThe \"name\" must match your module's package name. The \"version\" parameter must match your\nmodule's $VERSION variable and they must be considered valid by \"version::parse\".\n\nNOTE: These are Inline's sanity checks to make sure you know what you're doing\nbefore uploading your code to CPAN. They insure that once the module has\nbeen installed on someone's system, the module would not get\nautomatically recompiled for any reason. This makes Inline based modules\nwork in exactly the same manner as XS based ones.\n\nFinally, you need to modify the Makefile.PL. Simply change:\n\nuse ExtUtils::MakeMaker;\n\nto\n\nuse Inline::MakeMaker;\n\nAnd, in order that the module build work correctly in the cpan shell, add the following\ndirective to the Makefile.PL's WriteMakefile():\n\nCONFIGUREREQUIRES  =>  {\n'Inline::MakeMaker'     => 0.45,\n'ExtUtils::MakeMaker'   => 6.52,\n},\n\nThis \"CONFIGUREREQUIRES\" directive ensures that the cpan shell will install Inline on the\nuser's machine (if it's not already present) before building your Inline-based module.\nSpecifying of \"ExtUtils::MakeMaker => 6.52,\" is optional, and can be omitted if you like. It\nensures only that some harmless warnings relating to the \"CONFIGUREREQUIRES\" directive won't\nbe emitted during the building of the module. It also means, of course, that\nExtUtils::Makemaker will first be updated on the user's machine unless the user already has\nversion 6.52 or later.\n\nIf the \"Inline->init();\" is not done then, having installed Math::Simple, a warning that \"One\nor more DATA sections were not processed by Inline\" will appear when (and only when)\nMath::Simple is loaded by a \"require call. It's a harmless warning - and if you're prepared\nto live with it, then there's no need to make the \"Inline->init();\" call.\n\nWhen the person installing \"Math::Simple\" does a \"\"make\"\", the generated Makefile will invoke\nInline in such a way that the C code will be compiled and the executable code will be placed\ninto the \"./blib\" directory. Then when a \"\"make install\"\" is done, the module will be copied\ninto the appropriate Perl sitelib directory (which is where an installed module should go).\n\nNow all you need to do is:\n\nperl Makefile.PL\nmake dist\n\nThat will generate the file \"Math-Simple-0.20.tar.gz\" which is a distributable package. (It\nwill also generate some harmless warnings in relation to \"CONFIGUREREQUIRES\" unless the\nversion of your ExtUtils::MakeMaker is 6.52 or later.) That's all there is to it.\n\nIMPORTANT NOTE: Although the above steps will produce a workable module, you still have a few\nmore responsibilities as a budding new CPAN author. You need to write lots of documentation\nand write lots of tests. Take a look at some of the better CPAN modules for ideas on creating\na killer test harness.  Actually, don't listen to me, go read these:\n\n•   perldoc perlnewmod\n\n•   <http://www.cpan.org/modules/04pause.html>\n\n•   <http://www.cpan.org/modules/00modlist.long.html>\n",
                "subsections": []
            },
            "HOW INLINE WORKS": {
                "content": "In reality, Inline just automates everything you would need to do if you were going to do it\nby hand (using XS, etc).\n\nInline performs the following steps:\n\n•   Receive the Source Code\n\nInline gets the source code from your script or module with a statements like the\nfollowing:\n\nuse Inline C => \"Source-Code\";\n\nor\n\nuse Inline;\nbind Inline C => \"Source-Code\";\n\nwhere \"C\" is the programming language of the source code, and \"Source- Code\" is a string,\na file name, an array reference, or the special 'DATA' keyword.\n\nSince Inline is coded in a \"\"use\"\" statement, everything is done during Perl's compile\ntime. If anything needs to be done that will affect the \"Source- Code\", it needs to be\ndone in a \"BEGIN\" block that is before the \"\"use Inline ...\"\" statement. If you really\nneed to specify code to Inline at runtime, you can use the \"bind()\" method.\n\nSource code that is stowed in the 'DATA' section of your code, is read in by an \"INIT\"\nsubroutine in Inline. That's because the \"DATA\" filehandle is not available at compile\ntime.\n\n•   Check if the Source Code has been Built\n\nInline only needs to build the source code if it has not yet been built. It accomplishes\nthis seemingly magical task in an extremely simple and straightforward manner. It runs\nthe source text through the \"Digest::MD5\" module to produce a 128-bit \"fingerprint\" which\nis virtually unique. The fingerprint along with a bunch of other contingency information\nis stored in a \".inl\" file that sits next to your executable object. For instance, the\n\"C\" code from a script called \"example.pl\" might create these files:\n\nexamplepl3a9a.so\nexamplepl3a9a.inl\n\nIf all the contingency information matches the values stored in the \".inl\" file, then\nproceed to step 8. (No compilation is necessary)\n\n•   Find a Place to Build and Install\n\nAt this point Inline knows it needs to build the source code. The first thing to figure\nout is where to create the great big mess associated with compilation, and where to put\nthe object when it's done.\n\nBy default Inline will try to build and install under the first place that meets one of\nthe following conditions:\n\n1.  The DIRECTORY= config option; if specified\n\n2.  The \"PERLINLINEDIRECTORY\" environment variable; if set\n\n3.  \".Inline/\" (in current directory); if exists and \"$PWD != $HOME\"\n\n4.  bin.Inline (in directory of your script); if exists\n\n5.  \"~/.Inline/\" - if exists\n\n6.  \"./Inline/\" - if exists\n\n7.  \"bin/Inline\" - if exists\n\n8.  Create \"./Inline/\" - if possible\n\n9.  Create \"bin/Inline/\" - if possible\n\nFailing that, Inline will croak. This is rare and easily remedied by just making a\ndirectory that Inline will use.\n\nIf the \"PERLINSTALLROOT\" Environment Variable has been set, you will need to make\nspecial provision for that if the 'make install' phase of your Inline scripts are to\nsucceed.\n\nIf the module option is being compiled for permanent installation, then Inline will only\nuse \"./Inline/\" to build in, and the $Config{installsitearch} directory to install the\nexecutable in. This action is caused by Inline::MakeMaker, and is intended to be used in\nmodules that are to be distributed on the CPAN, so that they get installed in the proper\nplace.\n\n•   Parse the Source for Semantic Cues\n\nInline::C uses the module \"Parse::RecDescent\" to parse through your chunks of C source\ncode and look for things that it can create run-time bindings to. In \"C\" it looks for all\nof the function definitions and breaks them down into names and data types. These\nelements are used to correctly bind the \"C\" function to a \"Perl\" subroutine. Other Inline\nlanguages like Python and Java actually use the \"python\" and \"javac\" modules to parse the\nInline code.\n\n•   Create the Build Environment\n\nNow Inline can take all of the gathered information and create an environment to build\nyour source code into an executable. Without going into all the details, it just creates\nthe appropriate directories, creates the appropriate source files including an XS file\n(for C) and a \"Makefile.PL\".\n\n•   Build the Code and Install the Executable\n\nThe planets are in alignment. Now for the easy part. Inline just does what you would do\nto install a module. \"`perl Makefile.PL && make && make test && make install>\". If\nsomething goes awry, Inline will croak with a message indicating where to look for more\ninfo.\n\n•   Tidy Up\n\nBy default, Inline will remove all of the mess created by the build process, assuming\nthat everything worked. If the build fails, Inline will leave everything intact, so that\nyou can debug your errors. Setting the \"noclean\" shortcut option will also stop Inline\nfrom cleaning up.\n\n•   DynaLoad the Executable\n\nFor C (and C++), Inline uses the \"DynaLoader::bootstrap\" method to pull your external\nmodule into \"Perl\" space. Now you can call all of your external functions like Perl\nsubroutines.\n\nOther languages like Python and Java, provide their own loaders.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "For information about using Inline with C see Inline::C.\n\nFor sample programs using Inline with C see Inline::C-Cookbook.\n\nFor \"Formerly Answered Questions\" about Inline, see Inline-FAQ.\n\nFor information on supported languages and platforms see Inline-Support.\n\nFor information on writing your own Inline Language Support Module, see Inline-API.\n\nInline's mailing list is inline@perl.org\n\nTo subscribe, send email to inline-subscribe@perl.org\n",
                "subsections": []
            },
            "BUGS AND DEFICIENCIES": {
                "content": "When reporting a bug, please do the following:\n\n•   Put \"use Inline 'reportbug';\" at the top of your code, or use the command line option\n\"perl -MInline=reportbug ...\".\n\n•   Run your code.\n\n•   Follow the printed directions.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Ingy döt Net <ingy@cpan.org>\n\nSisyphus <sisyphus@cpan.org> fixed some bugs and is current co-maintainer.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "•   Copyright 2000-2019. Ingy döt Net.\n\n•   Copyright 2008, 2010-2014. Sisyphus.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms\nas Perl itself.\n\nSee <http://www.perl.com/perl/misc/Artistic.html>\n\n\n\nperl v5.30.0                                 2020-01-12                                  Inline(3pm)",
                "subsections": []
            }
        }
    }
}