#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; # Read in the responses to each item and save those responses locally $v01= $query->param('v01'); $v02= $query->param('v02'); $v03= $query->param('v03'); $v04= $query->param('v04'); $v05= $query->param('v05'); $v06= $query->param('v06'); $v07= $query->param('v07'); $v08= $query->param('v08'); $v01= $query->param('v09'); $v02= $query->param('v10'); $v11= $query->param('v11'); $v12= $query->param('v12'); $v13= $query->param('v13'); $v14= $query->param('v14'); $v15= $query->param('v15'); $v16= $query->param('v16'); $v17= $query->param('v17'); $v18= $query->param('v18'); $v19= $query->param('v19'); $v20= $query->param('v20'); # get date and time ($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"; # Create a composite score (average the responses to all the items) $disgust = ((6-$v15) + $v16 + $v17 + (6-$v18) + $v19 + $v20)/6; # Round the score to 2 decimal places and assign it a new variable name $disgust2 = sprintf("%.2f", $disgust); # Composite score for short relationships if($rellength <= 12){ $disgustshort = ((6-$v15) + $v16 + $v17 + (6-$v18) + $v19 + $v20)/6; $disgustshort2 = sprintf("%.2f", $disgustshort); } # Composite score for long relationships if($rellength > 12){ $disgustlong = ((6-$v15) + $v16 + $v17 + (6-$v18) + $v19 + $v20)/6; $disgustlong2 = sprintf("%.2f", $disgustlong); } # Create a relationship length variable $rellength = (($v05*12) + $v06); open(INFO, ">>$ENV{'DOCUMENT_ROOT_OLD'}/www/relationshipsresearch.com/P593/HW3.txt"); print INFO "$date1,$date2,"; print INFO "$v01,$v02,$v03,$v04,$v05,$v06,$v07,$v08,$v09,$v10,$v11,$v12,$v13,$v14,$v15,$v16,$v17,$v18,$v19,$v20,$disgust2,$rellength,$disgustshort2,$disgustlong2,"; print INFO "endline\n"; close (INFO); $sum= 0; $n= 0; open(INFO, "$ENV{'DOCUMENT_ROOT_OLD'}/www/relationshipsresearch.com/P593/HW3.txt"); @data = ; close(INFO); foreach $key (@data) { @a = split(/,/,$key); $sum= $sum + $a[22]; $n= $n + 1; } $disgustmean = $sum/$n; $disgustmean2 = sprintf("%.2f", $disgustmean); # Disgust mean for short past relationships (one year or less) if($rellength <= 12){ foreach $key (@data) { @a = split(/,/,$key); $sum= $sum + $a[24]; $n= $n + 1; } $disgustmeanshort = $sum/$n; $disgustmeanshort2 = sprintf("%.2f", $disgustmeanshort); } # Disgust mean for long past relationships (more than a year) if($rellength > 12){ foreach $key (@data) { @a = split(/,/,$key); $sum= $sum + $a[25]; $n= $n + 1; } $disgustmeanlong = $sum/$n; $disgustmeanlong2 = sprintf("%.2f", $disgustmeanlong); } print $query->header; print $query->start_html(-title=>'Thank You'); print ""; print ""; print ""; print ""; print ""; } } print $query->end_html;
"; print ""; print "
Thank you for participating in the study. Have a nice day.


"; print ""; print "Your disgust score is $disgust2 on a scale ranging from 1 (low disgust) to 5 (high disgust).

"; #Compared to whole sample average if($disgust2 >= $disgustmean){ print "Your disgust score is above or equal to the average score for all participants ($disgustmean2).

"; } if($disgust2 < $disgustmean){ print "Your disgust score is below the average score for all participants in the study ($disgustmean2).

"; } #Comparison for short past relationships if($rellength <= 12){ if($disgust2 < $disgustmeanshort){ print "Your disgust score is below the average score for all participants who were in their former relationship for a year or less ($disgustmeanshort2).

"; } if($disgust2 >= $disgustmeanshort){ print "Your disgust score is above or equal to the average score for all participants who were in their former relationship for a year or less ($disgustmeanshort2).

"; } } #Comparison for long past relationships if($rellength > 12){ if($disgust2 < $disgustmeanlong){ print "Your disgust score is below the average score for all participants who were in their former relationship for more than a year ($disgustmeanlong2).

"; } if($disgust2 >= $disgustmeanlong){ print "Your disgust score is above or equal to the average score for all participants who were in their former relationship for more than a year ($disgustmeanlong2).