{
    "mode": "perldoc",
    "parameter": "Text::Template::Preprocess",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Text%3A%3ATemplate%3A%3APreprocess/json",
    "generated": "2026-10-07T21:18:36Z",
    "synopsis": "use Text::Template::Preprocess;\nmy $t = Text::Template::Preprocess->new(...);  # identical to Text::Template\n# Fill in template, but preprocess each code fragment with pp().\nmy $result = $t->fillin(..., PREPROCESSOR => \\&pp);\nmy $oldpp = $t->preprocessor(\\&newpp);",
    "sections": {
        "NAME": {
            "content": "Text::Template::Preprocess - Expand template text with embedded Perl\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 1.61\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Text::Template::Preprocess;\n\nmy $t = Text::Template::Preprocess->new(...);  # identical to Text::Template\n\n# Fill in template, but preprocess each code fragment with pp().\nmy $result = $t->fillin(..., PREPROCESSOR => \\&pp);\n\nmy $oldpp = $t->preprocessor(\\&newpp);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Text::Template::Preprocess\" provides a new \"PREPROCESSOR\" option to \"fillin\". If the\n\"PREPROCESSOR\" option is supplied, it must be a reference to a preprocessor subroutine. When\nfilling out a template, \"Text::Template::Preprocessor\" will use this subroutine to preprocess\nthe program fragment prior to evaluating the code.\n\nThe preprocessor subroutine will be called repeatedly, once for each program fragment. The\nprogram fragment will be in $. The subroutine should modify the contents of $ and return.\n\"Text::Template::Preprocess\" will then execute contents of $ and insert the result into the\nappropriate part of the template.\n\n\"Text::Template::Preprocess\" objects also support a utility method, preprocessor(), which sets a\nnew preprocessor for the object. This preprocessor is used for all subsequent calls to \"fillin\"\nexcept where overridden by an explicit \"PREPROCESSOR\" option. preprocessor() returns the\nprevious default preprocessor function, or undefined if there wasn't one. When invoked with no\narguments, preprocessor() returns the object's current default preprocessor function without\nchanging it.\n\nIn all other respects, \"Text::Template::Preprocess\" is identical to \"Text::Template\".\n\nWHY?\nOne possible purpose: If your files contain a lot of JavaScript, like this:\n\nPlain text here...\n{ perl code }\n<script language=JavaScript>\nif (br== \"n3\") {\n// etc.\n}\n</script>\n{ more perl code }\nMore plain text...\n\nYou don't want \"Text::Template\" to confuse the curly braces in the JavaScript program with\nexecutable Perl code. One strategy:\n\nsub quotescripts {\ns(<script(.*?)</script>)(q{$1})gsi;\n}\n\nThen use \"PREPROCESSOR => \\&quotescripts\". This will transform\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Text::Template\n",
            "subsections": []
        },
        "SOURCE": {
            "content": "The development version is on github at <https://https://github.com/mschout/perl-text-template>\nand may be cloned from <git://https://github.com/mschout/perl-text-template.git>\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs or feature requests on the bugtracker website\n<https://github.com/mschout/perl-text-template/issues>\n\nWhen submitting a bug or request, please include a test-file or a patch to an existing test-file\nthat illustrates the bug or desired feature.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Mark Jason Dominus, Plover Systems\n\nPlease send questions and other remarks about this software to \"mjd-perl-template+@plover.com\"\n\nYou can join a very low-volume (<10 messages per year) mailing list for announcements about this\npackage. Send an empty note to \"mjd-perl-template-request@plover.com\" to join.\n\nFor updates, visit \"http://www.plover.com/~mjd/perl/Template/\".\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2013 by Mark Jason Dominus <mjd@cpan.org>.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Text::Template::Preprocess - Expand template text with embedded Perl",
    "flags": [],
    "examples": [],
    "see_also": []
}