use FormManager; my $query = new CGI(); my $fm = new FormManager (layout => [new FormManager::Text (name => 'phone_number', heading => 'Enter your phone number', validate => 'phone'), new FormManager::Select (name => 'likes_ice_cream', heading => 'Do you like ice cream?', option_list => ['Yes', 'No']), new FormManager::Hidden (name => 'action', value => 'submit_this_form') ], form_submit => 'Submit this form' ); print "Content-Type: text/html\n\n"; # This script can be called in two ways # 1) Initially to get the form # 2) By submitting the form # If this is case 1) if ($query->param ('action') ne 'submit_this_form') { print $fm->getHtml(); } else { # Ensure that the input is valid. If not, re-print the form if (!$fm->processQuery()) { print $fm->getHtml(); } else { print "Your phone number is : " . $fm->getValue ('phone_number')" . " and you " . ($fm->getValue ('likes_ice_cream') eq 'No' ? "don't like ice cream." : "like ice cream."); } }