{
    "mode": "perldoc",
    "parameter": "Inline",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Inline/json",
    "generated": "2026-07-05T13:02:57Z",
    "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}",
    "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 normal.\nAll the hairy details are handled for you. The compilation and installation of your code chunks\nall happen transparently; all you will notice is the delay of compilation on the first run.\n\nThe Inline code only gets compiled the first time you run it (or whenever it is modified) so you\nonly take the performance hit once. Code that is Inlined into distributed modules (like on the\nCPAN) will get compiled when the module is installed, so the end user will never notice the\ncompilation time.\n\nBest of all, it works the same on both Unix and Microsoft Windows. See Inline- Support for\nsupport information.\n\nWhy Inline?\nDo you want to know \"Why would I use other languages in Perl?\" or \"Why should I use Inline to do\nit?\"? 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. Many\npeople will say \"Anything Perl can do, C can do faster\". (They never mention the development\ntime :-) Anyway, you may be able to remove a bottleneck in your Perl code by using another\nlanguage, without having to write the entire program in that language. This keeps your\noverall development time down, because you're using Perl for all of the non-critical code.\n\nAnother reason is to access functionality from existing API-s that use the language. Some of\nthis code may only be available in binary form. But by creating small subroutines in the\nnative language, you can \"glue\" existing libraries to your Perl. As a user of the CPAN, you\nknow that code reuse is a good thing. So why throw away those Fortran libraries just yet?\n\nIf you are using Inline with the C language, then you can access the full internals of Perl\nitself. 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. Both\nare similar in their capabilities, at least as far as Perl is concerned. And both of them\nare quite difficult to learn compared to Inline.\n\nThere is a big fat learning curve involved with setting up and using the XS environment. You\nneed 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 short\nbut complete programs that you can extend to your real-life problems. No need to learn about\nthe complicated build process going on in the background. You don't even need to compile the\ncode yourself. Inline takes care of every last detail except writing the C code.\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 it\nin a Perl one-liner. With XS and SWIG, you always set up an entirely separate module. Even\nif you only have one or two functions. Inline makes easy things easy, and hard things\npossible. 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 Language\nSupport Modules (ILSMs) are regularly being added. See Inline-API for details on how to\ncreate your own ILSM.\n\nUSING THE INLINE.PM MODULE\nInline is a little bit different than most of the Perl modules that you are used to. It doesn't\nimport any functions into your namespace and it doesn't have any object oriented methods. Its\nentire interface (with two minor exceptions) is specified through the 'use Inline ...' command.\n\nThis section will explain all of the different ways to \"use Inline\". If you want to begin using\nC with Inline immediately, see Inline::C-Cookbook.\n",
            "subsections": [
                {
                    "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 identifies\nthe source code that you want to bind to Perl. The source code can be specified using any of the\nfollowing 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 marker\nin your \"DATA\" filehandle's input stream. In this example the special marker is \"Java\",\nwhich 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 excellent\nside benefit is that you don't have to escape any characters like you might in a Perl\nstring. The source code is verbatim. For these reasons, I prefer this method the most.\n\nThe only problem with this style is that since Perl can't read the \"DATA\" filehandle until\nruntime, it obviously can't bind your functions until runtime. The net effect of this is\nthat you can't use your Inline functions as barewords (without predeclaring them) because\nPerl 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 files.\nThe special '\"DATA\"' keyword is replaced by either '\"file\"' or '\"below\"'. This allows for\nthe 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 these\nsections from your program before Perl compiles it. They are then available for Inline to\nmake use of. And since this can all be done at compile time, you don't have to worry about\nthe 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, there\nis 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 do\nwith Inline::Files is to get line number info so when an extension doesn't compile, the\nerror 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 improves),\nbut 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 is\nto use Perl's \"here document\" style of quoting. This is ok for small functions but can get\nunwieldy in the large. On the other hand, the string variant probably has the least startup\npenalty 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 set\nat 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 above)\nThe \"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 for\ncreating modules with Inline.\n\nOther Methods\nThe source code for Inline can also be specified as an external filename, a reference to a\nsubroutine 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 be\nspecified with a leading '.*' - ie '.*file.ext' instead of simply 'file.ext'.) These methods\nare 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 helper\nmodule \"Inline::Filters\", you can even use POD inside your Inline code. You just have to specify\na filter to strip it out.\n\nYou can also specify multiple Inline sections, possibly in different programming languages. Here\nis 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 each\n\"Foo\" marker, and they must be in the same order. This allows you to apply different\nconfiguration 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 override\nthe default actions. This is easy to do. Simply list the Inline configuration options after the\nregular Inline parameters. All configuration options are specified as (key, value) 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 code\nwill be compiled or bound to Perl.\n\nIf you want to specify global configuration options that don't apply to a particular language,\njust 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. And\nyou can apply different options to different code sections. When a source code section is passed\nin, Inline will apply whichever options have been specified up to that point. Here is a complex\nconfiguration 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 array\nref forms, and do the right thing.) The \"Python\" section does not use the \"global\" library, but\ndoes use the same \"DIRECTORY\", and has warnings turned off. The second \"C\" section only uses the\n\"local3\" library. That's because a value of \"undef\" resets the additive behavior.\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 from\nother 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. Since\n\"Event\" has a C API of its own, it can pass Inline all of the information it needs to be able to\nuse \"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 relevant\nILSM. 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 called\n'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\", use\nthe 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. If\nInline cannot find the directory in any of these places it will create a 'Inline/' directory in\neither 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 to\nforce 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. Things\nlike XS files, Makefiles and output log files.\n\nIf everything goes OK, Inline will delete this subdirectory. If there is an error, Inline will\nleave the directory intact and print its location. The idea is that you are supposed to go into\nthat 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 your\nnewly 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 an\nextension.\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 you.\n\n\"name\"\nYou can use this option to set the name of your Inline extension object module. For example:\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 sync\nwith 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 in a\nsmall 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. Objects\ncreated with \"autoname\" will never get replaced. That also means they will never get cleaned\nup automatically.\n\n\"autoname\" is very useful for small throw away scripts. For more serious things, always use\nthe \"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 it\notherwise.\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 typically\nused to override the default parser for Inline::C, but might be used by any ILSM for any\npurpose.\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 option\ntells Inline to blindly untaint all tainted variables. (This is generally considered to be\nan appallingly insecure thing to do, and not to be recommended - but the option is there for\nyou to use if you want. Please consider using something other than Inline for scripts that\nneed taint checking.) It also turns on \"safemode\" by default. See the \"untaint\" shortcut\nbelow. You will see warnings about blindly untainting fields in both %ENV and Inline\nobjects. If you want to silence these warnings, set the Config option \"nountaintwarn\" =>\n1. There can be some problems untainting Inline scripts where older versions of Cwd, such as\nthose that shipped with early versions of perl-5.8 (and earlier), are installed. Updating\nCwd 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\" automatically\nturns this option on. If you need your code to start faster under \"-T\" (taint) checking,\nyou'll need to turn this option off manually. Only do this if you are not worried about\nsecurity risks. See the \"unsafe\" shortcut below.\n\n\"forcebuild\"\nMakes Inline build (compile) the source code every time the program is run. The default is\n0. See the \"force\" shortcut below.\n\n\"buildnoisy\"\nTells ILSMs that they should dump build messages to the terminal rather than be silent about\nall 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 you\nwant 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\". Default\nis 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. Specify\nthem 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 used for additional\npurposes.\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 are\nwhen 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 tells\nInline to print helpful information to \"STDERR\". Among the things that get printed is a list\nof 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 a\nbug. \"reportbug\" also automatically forces a build, and doesn't clean up afterwards. This is\nso that you can tar and mail the build directory to me. \"reportbug\" will print exact\ninstructions 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 have tar,\nplease 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 removed\nfrom Inline altogether and replaced with a much simpler and more powerful mechanism,\n\"Inline::MakeMaker\". See the section below on how to create modules with Inline.\n\n\"testing\"\nUsed internally by C*t*09parser.t and C*t*10callback.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 warning.\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 is\ndefinitely not a recommended way of dealing with taint checking, but it's the only option\ncurrently 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 like\nInline::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 also\nintegrates 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 following\ncommand:\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 before uploading\nyour code to CPAN. They insure that once the module has been installed on someone's system, the\nmodule would not get automatically 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 be\nemitted during the building of the module. It also means, of course, that ExtUtils::Makemaker\nwill first be updated on the user's machine unless the user already has version 6.52 or later.\n\nIf the \"Inline->init();\" is not done then, having installed Math::Simple, a warning that \"One or\nmore DATA sections were not processed by Inline\" will appear when (and only when) Math::Simple\nis loaded by a \"require call. It's a harmless warning - and if you're prepared to live with it,\nthen 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 will\nalso generate some harmless warnings in relation to \"CONFIGUREREQUIRES\" unless the version of\nyour 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 and\nwrite lots of tests. Take a look at some of the better CPAN modules for ideas on creating a\nkiller 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 by\nhand (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 following:\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, a\nfile 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 time.\nIf anything needs to be done that will affect the \"Source- Code\", it needs to be done in a\n\"BEGIN\" block that is *before* the \"\"use Inline ...\"\" statement. If you really need to\nspecify 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 time.\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 the\nsource text through the \"Digest::MD5\" module to produce a 128-bit \"fingerprint\" which is\nvirtually unique. The fingerprint along with a bunch of other contingency information is\nstored in a \".inl\" file that sits next to your executable object. For instance, the \"C\" code\nfrom 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 out\nis where to create the great big mess associated with compilation, and where to put the\nobject when it's done.\n\nBy default Inline will try to build and install under the first place that meets one of the\nfollowing 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 directory\nthat Inline will use.\n\nIf the \"PERLINSTALLROOT\" Environment Variable has been set, you will need to make special\nprovision for that if the 'make install' phase of your Inline scripts are to succeed.\n\nIf the module option is being compiled for permanent installation, then Inline will only use\n\"./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 code\nand look for things that it can create run-time bindings to. In \"C\" it looks for all of the\nfunction definitions and breaks them down into names and data types. These elements are used\nto correctly bind the \"C\" function to a \"Perl\" subroutine. Other Inline languages like\nPython and Java actually use the \"python\" and \"javac\" modules to parse the Inline code.\n\n*   Create the Build Environment\n\nNow Inline can take all of the gathered information and create an environment to build your\nsource code into an executable. Without going into all the details, it just creates the\nappropriate directories, creates the appropriate source files including an XS file (for C)\nand 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 to\ninstall a module. \"`perl Makefile.PL && make && make test && make install>\". If something\ngoes awry, Inline will croak with a message indicating where to look for more info.\n\n*   Tidy Up\n\nBy default, Inline will remove all of the mess created by the build process, assuming that\neverything worked. If the build fails, Inline will leave everything intact, so that you can\ndebug your errors. Setting the \"noclean\" shortcut option will also stop Inline from cleaning\nup.\n\n*   DynaLoad the Executable\n\nFor C (and C++), Inline uses the \"DynaLoader::bootstrap\" method to pull your external module\ninto \"Perl\" space. Now you can call all of your external functions like Perl subroutines.\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 \"perl\n-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 as\nPerl itself.\n\nSee <http://www.perl.com/perl/misc/Artistic.html>\n",
            "subsections": []
        }
    },
    "summary": "Inline - Write Perl Subroutines in Other Programming Languages",
    "flags": [],
    "examples": [],
    "see_also": []
}