HTML::Mason does not depend on mod_perl, but it can use it ;-)
Here's your example rendered through Mason:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Mason;
sub foo { $_[0] + $_[1] }
my $template = << 'END';
This is some line.
This is a line with some expression: <% foo(3,5) %>
% for my $s qw(this that) {
This is <% $s %> line
% }
This is the end
END
my $output;
my $interp = HTML::Mason::Interp->new( out_method => \$output,
in_package => __PACKAGE__,
);
my $comp = $interp->make_component( comp_source => $template );
$interp->exec($comp);
print $output;
You mentioned you don't care too much about the syntax, that's why I preferred do not show you how to override Mason's default syntax. Check out http://masonhq.com/docs/manual/ if you're interested.