#!/usr/bin/perl

use strict;
use warnings;

use CGI;
use Template;

my $cgi = CGI->new;
my $template_vars;

if ( $cgi->param ) {
	foreach my $var ( qw/ magnification letter x y / ) {
		$template_vars->{$var} = $cgi->param(
			$var =~ /^[xy]$/ ? "picture.$var" : $var
		);
	}
}

my $tt  = Template->new;
print $cgi->header(
    -type    => 'text/html',
    -charset => 'utf-8',
);

$tt->process( \*DATA,$template_vars ) or warn $tt->error;

__DATA__
<!DOCTYPE html>

		A Clickable Image

A Clickable Image

Sorry, this isn't very exciting!

Give me a:
			[%- FOREACH letter_opt IN [ 'A','B','C','D','E','W' ] %]
				[% letter_opt %]
			[%- END %]

Magnification:
			[% FOREACH magnification_opt IN [ 1,2,4,20 ] -%]
				[%- %][% magnification_opt %]X
			[% END -%]
			[%- IF x.defined AND y.defined %]
				
Selected Position ([% x %],[% y %])
			[% END %]

