# Start the page and form creation process as required $co = HTML::Tiny->new( mode => 'html' ); if ($co->param()) { #data returned from the form submission print "data present - to be analysed\n"; $buffer = ""; if($ENV{'REQUEST_METHOD'} eq "POST") { # POST method retrieves data by the READ command print "POST read\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { # GET method retrieves by accessing the relevant environment variable print "Query String\n"; $buffer = $ENV{'QUERY_STRING'}; } print ("buffer=

$buffer

"); if (length ($buffer) > 0) { # Analyse the form data .... } else { print "

buffer size is zero

"; exit; } } else { # No data passed to here by a submit - create the display form that is required to do so print "no data present -to display form\n"; displayForm(); }