From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!/usr/bin/env perl -w
# Simple Subclassing
package MyTTS;
use strict;
use lib qw(t/lib lib);
use Text::Template::Simple::Constants qw(:fields); # get the object fields
use MyUtil;
sub new {
my $class = shift;
my $self = $class->SUPER::new( @_ );
_p "Sub class defined the constructor!\n";
return $self;
}
sub compile {
my $self = shift;
_p 'Delimiters are: ' . join( ' & ', @{$self->[DELIMITERS] }) . "\n";
return $self->SUPER::compile( @_ );
}
package main;
use strict;
use Test::More qw( no_plan );
ok(my $t = MyTTS->new, 'object');
ok( $t->compile(q/Just a test/), 'Compiled by subclass');