#!/bin/perl5 use strict; use warnings; use CGI::Carp qw( fatalsToBrowser ); package main; my $webapp = App->new(); $webapp->run(); package App; use base 'CGI::Application'; use CGI; sub cgiapp_get_query { my $self = shift; # initilise the query object # with some params my $q = CGI->new( { 'test' => 'test page', 'greeting' => 'Hi there!', } ); return $q; } sub setup { my $self = shift; $self->start_mode('test'); $self->run_modes([qw|test|]); } sub test{ my $self = shift; my $html; { local $/; $html = ; } my $tmpl_obj = $self->load_tmpl( \$html, associate => $self->query, ); return $tmpl_obj->output(); } __DATA__ <!-- TMPL_VAR NAME = TEST -->