{
    "mode": "perldoc",
    "parameter": "TAP::Parser::SourceHandler::Perl",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/TAP%3A%3AParser%3A%3ASourceHandler%3A%3APerl/json",
    "generated": "2026-06-10T13:43:54Z",
    "synopsis": "use TAP::Parser::Source;\nuse TAP::Parser::SourceHandler::Perl;\nmy $source = TAP::Parser::Source->new->raw( \\'script.pl' );\n$source->assemblemeta;\nmy $class = 'TAP::Parser::SourceHandler::Perl';\nmy $vote  = $class->canhandle( $source );\nmy $iter  = $class->makeiterator( $source );",
    "sections": {
        "NAME": {
            "content": "TAP::Parser::SourceHandler::Perl - Stream TAP from a Perl executable\n",
            "subsections": []
        },
        "VERSION": {
            "content": "Version 3.43\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use TAP::Parser::Source;\nuse TAP::Parser::SourceHandler::Perl;\n\nmy $source = TAP::Parser::Source->new->raw( \\'script.pl' );\n$source->assemblemeta;\n\nmy $class = 'TAP::Parser::SourceHandler::Perl';\nmy $vote  = $class->canhandle( $source );\nmy $iter  = $class->makeiterator( $source );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a *Perl* TAP::Parser::SourceHandler - it has 2 jobs:\n\n1. Figure out if the TAP::Parser::Source it's given is actually a Perl script (\"canhandle\").\n\n2. Creates an iterator for Perl sources (\"makeiterator\").\n\nUnless you're writing a plugin or subclassing TAP::Parser, you probably won't need to use this\nmodule directly.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Class Methods",
                    "content": "\"canhandle\"\nmy $vote = $class->canhandle( $source );\n\nOnly votes if $source looks like a file. Casts the following votes:\n\n0.9  if it has a shebang ala \"#!...perl\"\n0.75 if it has any shebang\n0.8  if it's a .t file\n0.9  if it's a .pl file\n0.75 if it's in a 't' directory\n0.25 by default (backwards compat)\n\n\"makeiterator\"\nmy $iterator = $class->makeiterator( $source );\n\nConstructs & returns a new TAP::Parser::Iterator::Process for the source. Assumes \"$source->raw\"\ncontains a reference to the perl script. \"croak\"s if the file could not be found.\n\nThe command to run is built as follows:\n\n$perl @switches $perlscript @testargs\n\nThe perl command to use is determined by \"getperl\". The command generated is guaranteed to\npreserve:\n\nPERL5LIB\nPERL5OPT\nTaint Mode, if set in the script's shebang\n\n*Note:* the command generated will *not* respect any shebang line defined in your Perl script.\nThis is only a problem if you have compiled a custom version of Perl or if you want to use a\nspecific version of Perl for one test and a different version for another, for example:\n\n#!/path/to/a/customperl --some --args\n#!/usr/local/perl-5.6/bin/perl -w\n\nCurrently you need to write a plugin to get around this.\n\n\"gettaint\"\nDecode any taint switches from a Perl shebang line.\n\n# $taint will be 't'\nmy $taint = TAP::Parser::SourceHandler::Perl->gettaint( '#!/usr/bin/perl -t' );\n\n# $untaint will be undefined\nmy $untaint = TAP::Parser::SourceHandler::Perl->gettaint( '#!/usr/bin/perl' );\n\n\"getperl\"\nGets the version of Perl currently running the test suite.\n"
                }
            ]
        },
        "SUBCLASSING": {
            "content": "Please see \"SUBCLASSING\" in TAP::Parser for a subclassing overview.\n",
            "subsections": [
                {
                    "name": "Example",
                    "content": "package MyPerlSourceHandler;\n\nuse strict;\n\nuse TAP::Parser::SourceHandler::Perl;\n\nuse base 'TAP::Parser::SourceHandler::Perl';\n\n# use the version of perl from the shebang line in the test file\nsub getperl {\nmy $self = shift;\nif (my $shebang = $self->shebang( $self->{file} )) {\n$shebang =~ /^#!(.*\\bperl.*?)(?:(?:\\s)|(?:$))/;\nreturn $1 if $1;\n}\nreturn $self->SUPER::getperl(@);\n}\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory, TAP::Parser::SourceHandler,\nTAP::Parser::SourceHandler::Executable, TAP::Parser::SourceHandler::File,\nTAP::Parser::SourceHandler::Handle, TAP::Parser::SourceHandler::RawTAP\n",
            "subsections": []
        }
    },
    "summary": "TAP::Parser::SourceHandler::Perl - Stream TAP from a Perl executable",
    "flags": [],
    "examples": [],
    "see_also": []
}