#!/usr/bin/perl use Template; print "Content-type: text/html\n\n"; use CGI qw(:standard); @words=("sparrow","wax","field","tear"); $theword=$words[rand @words]; $startwin=0; $startlose=0; $game=param('submit'); $win=param('win'); $lose=param('lose'); $response=param('response'); $arrow=param('arrow'); $axe=param('axe'); $shield=param('shield'); $spear=param('spear'); $correctryhm=param('correctryhm'); #another way of setting up a hash #needs to know where the templates are my $config={ INCLUDE_PATH =>'../../projectTemplate', #or list ref INTERPOLATE => 1, #expand '$var' in plain text POST_CHOMP => 1, #cleans up whitespace EVAL_PERL =>1, #evaluate Perl code blocks }; #
$output=<<_html_; _html_ print $output; #create a template object #-> means 'send to' my $template=Template->new($config); if($game eq "Fight") { if($response eq "arrow" and $correctryhm eq "sparrow") { $arrow=param('arrow'); $correctryhm=param('correctryhm'); $response=param('response'); $win=param('win'); $win=$win+1; } if($response eq "axe" and $correctryhm eq "wax") { $axe=param('axe'); $correctryhm=param('correctryhm'); $response=param('response'); $win=param('win'); $win=$win+1; } if($response eq "shield" and $correctryhm eq "field") { $shield=param('shield'); $correctryhm=param('correctryhm'); $response=param('response'); $win=param('win'); $win=$win+1; } if($response eq "spear" and $correctryhm eq "tear") { $spear=param('spear'); $correctryhm=param('correctryhm'); $response=param('response'); $win=param('win'); $win=$win+1; } else { $lose=param('lose'); $lose=$lose+1; } if ($win <= 9 and $lose <= 10) { print "