What are good alternatives to format/write (legacy), and how do they compare?

Exploring the alternatives to Perl's legacy format/write methods, we can look into various modern techniques that simplify string formatting and templating in Perl. These methods are more flexible and integrate seamlessly with newer Perl features.
perl, string formatting, templating, modern coding practices, alternatives
use strict;
use warnings;

# Example using sprintf for formatting
my $name = "John";
my $age = 30;
my $formatted_string = sprintf("My name is %s and I am %d years old.", $name, $age);

print $formatted_string;

# Example using Template Toolkit for templating
use Template;

my $template = Template->new();
$template->process(\<<'END_TEMPLATE', { name => 'John', age => 30 }) || die $template->error;

My name is [% name %] and I am [% age %] years old.

END_TEMPLATE

perl string formatting templating modern coding practices alternatives