#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; # Demonstration of how to use a Perl script to administer the survey # Import information from CGI data packet $v01= $query->param('v01'); $v02= $query->param('v02'); $v03= $query->param('v03'); $v04= $query->param('v04'); $v05= $query->param('v05'); $pass= $query->param('pass'); # Obtain current date and time from server ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = 1900 + $year; $mon= $mon+1; $hour = $hour - 1; $date1= "$mon/$mday/$year"; $date2= "$hour:$min:$sec"; # Prepare to send HTML code to browser print $query->header; print $query->start_html(-title=>'Thank You'); # Create styles print ""; # Compute a composite score (average the responses to all the items) $esteem = ($v01 + $v02 + (6-$v03) + $v04 + (6-$v05))/5; $esteem2 = sprintf("%.2f",$esteem); # Open the data file and append the new data to the last row open(INFO, ">>$ENV{'DOCUMENT_ROOT'}/P593/form3.txt"); print INFO "$date1,$date2,$v01,$v02,$v03,$v04,$v05,$esteem2,endline\n"; close (INFO); # Open the data file and dump its contents to @data open(INFO, "$ENV{'DOCUMENT_ROOT'}/P593/form3.txt"); @data = ; close(INFO); # Provide feedback print "Thank you for your participation. Your self-esteem score is $esteem2 on a scale ranging from 1 (low) to 5 (high).

"; print $query->end_html;