TAP::Object(3perl)
π TAP::Object β it's giving "base class energy" β¨
ok so this is TAP::Object, a page from the Perl Programmers Reference Guide (TAP::Object(3perl)), and bestieβ¦ it's literally the blueprint every TAP::* module is built on. the whole squad. π
πΈ NAME πΈ
TAP::Object β the base class that hands out the common functionality to all the TAP::* modules. every single one. no cap. π
π VERSION π
Version 3.52 β that's the one we're repping rn, periodt.
β¨ SYNOPSIS β¨
ok here's the whole vibe, look:
package TAP::Whatever;
use strict;
use base 'TAP::Object';
# new() implementation by TAP::Object
sub _initialize {
my ( $self, @args) = @_;
# initialize your object
return $self;
}
# ... later ...
my $obj = TAP::Whatever->new(@args);
see how chill that is? you inherit, you override _initialize, and new justβ¦ works. iconic behavior honestly. π¦
π DESCRIPTION π
TAP::Object gives every TAP::* class a default constructor and a whole exception model, for free, no effort, slay. exceptions get raised using Carp. that's the whole deal. π«Ά
π₯ METHODS π₯
π Class Methods
newβ makes you a brand new object β¨ any args you pass tonewget forwarded straight to the_initializemethod. returns a shiny new object. that's it, that's the method.
π§ Instance Methods
_initializeβ sets up a new object. heads up though: this one's just a stub by default, so you're supposed to override it and do your own thing. do not leave it blank and act surprised, bestie. π
Note:newexpects you toreturn $selfor raise an exception. that's the contract. look at_croak, and also at Carp. π
_croakβ raises an exception usingcroakfrom Carp, like so:
$self->_croak( 'why me?', 'aaarrgh!' );
and plot twist β you can call it as a class method too:
$class->_croak( 'this works too' );
_confessβ raises an exception usingconfessfrom Carp, same energy, different function:
$self->_confess( 'why me?', 'aaarrgh!' );
and yes, class method version exists too:
$class->_confess( 'this works too' );
_constructβ creates a brand new instance of whatever class you point it at. new object, who dis. πmk_methodsβ makes you simple getters/setters. one line, so many methods, megabrain:
__PACKAGE__->mk_methods(@method_names);
and that's the page!! thanks for coming to my ted talk π this was TAP::Object, part of the Perl Programmers Reference Guide, and this specific tea was spilled by perl v5.44.0 on 2026-10-17. go forth and inherit responsibly, bestie πβ¨π¦π
π¦ 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