TAP::P...::Perl(3perl)
πΈ NAME πΈ
TAP::Parser::SourceHandler::Perl β stream TAP straight outta a Perl executable, bestie π
(and yeah, this lives in the TAP::P...::Perl(3perl) manpage, ilysm Perl Programmers Reference Guide)
β¨ VERSION β¨
Version 3.52 β she's current, she's cute π
π«Ά SYNOPSIS π«Ά
use TAP::Parser::Source;
use TAP::Parser::SourceHandler::Perl;
my $source = TAP::Parser::Source->new->raw( \'script.pl' );
$source->assemble_meta;
my $class = 'TAP::Parser::SourceHandler::Perl';
my $vote = $class->can_handle( $source );
my $iter = $class->make_iterator( $source );
π DESCRIPTION π
So this is a Perl TAP::Parser::SourceHandler, and she has literally 2 jobs, no more no less:
- Figure out if the
TAP::Parser::Sourceshe's handed is actually a Perl script (can_handle). π - Create an iterator for Perl sources (
make_iterator). ποΈ
Heads up bestie: unless you're out here writing a plugin or subclassing TAP::Parser, you lowkey will not need to touch this module directly. She's backstage crew, not main character energy. π
π METHODS π
π Class Methods π
π₯ can_handle π₯
my $vote = $class->can_handle( $source );
She only votes if $source looks like a file, periodt. And then she casts these votes, fr fr:
0.9β if it has a shebang ala#!...perl0.3β if it has any shebang0.8β if it's a.tfile0.9β if it's a.plfile0.75β if it's in a't'directory0.25β by default (backwards compat, the nostalgia vote π₯²)
π¦ make_iterator π¦
my $iterator = $class->make_iterator( $source );
Constructs & returns a brand new TAP::Parser::Iterator::Process for the source. She's assuming $source->raw holds a reference to the perl script. And if the file couldn't be found? She croaks. π no file, no vibes.
The command she runs gets built like this:
$perl @switches $perl_script @test_args
Which perl command gets used is decided by get_perl. And the command she generates is guaranteed to preserve these, no cap:
PERL5LIB
PERL5OPT
Taint Mode, if set in the script's shebang
β οΈ Note, and this part matters: the command generated will not respect any shebang line defined in your Perl script. This is only a problem if you've compiled a custom version of Perl, or if you wanna use one specific Perl version for one test and a different one for another, like:
#!/path/to/a/custom_perl --some --args
#!/usr/local/perl-5.6/bin/perl -w
Currently you need to write a plugin to get around this. That's just how it is rn. π§
π get_taint π
Decodes any taint switches from a Perl shebang line. Detective work, but make it cute π
# $taint will be 't'
my $taint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl -t' );
# $untaint will be undefined
my $untaint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl' );
β get_perl β
Gets the version of Perl currently running the test suite. That's it, that's the whole function π
π SUBCLASSING π
Please see "SUBCLASSING" in TAP::Parser for a subclassing overview. Go read that first, bestie, don't skip it π«Ά
π Example π
package MyPerlSourceHandler;
use strict;
use TAP::Parser::SourceHandler::Perl;
use base 'TAP::Parser::SourceHandler::Perl';
# use the version of perl from the shebang line in the test file
sub get_perl {
my $self = shift;
if (my $shebang = $self->shebang( $self->{file} )) {
$shebang =~ /^#!(.*\bperl.*?)(?:(?:\s)|(?:$))/;
return $1 if $1;
}
return $self->SUPER::get_perl(@_);
}
π SEE ALSO π
- TAP::Object
- TAP::Parser
- TAP::Parser::IteratorFactory
- TAP::Parser::SourceHandler
- TAP::Parser::SourceHandler::Executable
- TAP::Parser::SourceHandler::File
- TAP::Parser::SourceHandler::Handle
- TAP::Parser::SourceHandler::RawTAP
okay that's the whole page, you ate it, go slay some tests πβ¨ this was perl v5.44.0, dated 2026-10-17, and it's the TAP::P...::Perl(3perl) page β bye bestie, love u, drink water π§πΈπ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms