#!/usr/local/bin/perl ############################### ## Very simple example of how ## to handle user input, ## from a form or url. ## Assume the user sets a variable 'var'. ## This script gets the value and prints it. ## Note the use of CGI.pm. ## Also note that 'var' is not set, ## this script issues a form and lets the ## user try again. ## use CGI; $parse = new CGI; $newvar = $parse->param('var'); if ($newvar) { print_output(); } else { print_form(); } exit; ########################### ## We have the value of 'var' ## so just print it out. ## sub print_output { print <Example The value of var is $newvar EOF } ########################### ## Just print out a normal html form. ## Note that the name of the input box is 'var'. ## Also note how the action is constructed. ## sub print_form { print <Example Form
Give me a value:
EOF }