use CGI; our $q = new CGI; sub do_form { my $href; $href->{key} = md5_hex(time() . '-' . $$ . '-' . rand()); to_template( output => $href, tmpl => 'form.tt' ); } sub to_template { my %hash = @_; print $q->header; require Template; my $template = HTML::Template -> new(filename => "/templates/$hash{tmpl}"); $template->param(map { defined $hash{output}->{$_} ? ($_ => $hash{output}->{$_}) : () } keys %{$hash{output}}); print $template->output; } sub process_form { my $params = $q->Vars; debug($params->{key}); }