#!/usr/bin/perl -w #this app is extremely simple - it's pretty much a sort of 'hello world' #MVC application using the CGI::Application framework. #-------- use CGI::Carp qw(fatalsToBrowser); package dictionarylookup; use CGI::Application; use base 'CGI::Application'; use strict; #run at startup;; sub setup { my $self = shift; $self->start_mode('show_search_form'); $self->mode_param('rm'); $self->run_modes([qw/show_search_form display_form_results/]); } #sub to show form; sub show_search_form{ my $self = shift; my $q = self->query(); my $out = ''; $out .= $q->_start_html(-title => 'Dictionary Word Lookup'); $out .= $q->start_form(); $out .= $q->textfield(-name=>'word', -size=>50, -maxlength=>50); $out .= $q->hidden(-name => 'rm', -value => 'display_form_results'); $out .= $q->submit(); $out .= $q->end_form(); $out .= $q->end_html(); return $out; } #sub to process/display results; #for now: just output the dang word! sub display_form_results{ my $self = shift; my $q = self->query(); my $tainted_word = $self->param('word'); my $out = ''; $out .= $q->_start_html(-title => 'Dictionary Word Lookup'); $out .= $q->h1($tainted_word); $out .= $q->end_html(); return $out; } 1;