#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; $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'); $pass= $query->param('pass'); if($pass < 1) { $pass=0; } ($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"; print $query->header; print $query->start_html(-title=>'Homework 4'); print ""; if($pass == 1) { #Analyze data. #Computes counts for number of times participant selected each response class (there are 6 total classes). @class = (0, 0, 0, 0, 0, 0); @variables = ($v01, $v02, $v03, $v04, $v05, $v06, $v07); foreach $variable (@variables) { if($variable == 1) {$class[0] = $class[0] + 1;} if($variable == 2) {$class[1] = $class[1] + 1;} if($variable == 3) {$class[2] = $class[2] + 1;} if($variable == 4) {$class[3] = $class[3] + 1;} if($variable == 5) {$class[4] = $class[4] + 1;} if($variable == 6) {$class[5] = $class[5] + 1;} } #Assigns summed class variables to individual variables outside of the array. This is necessary for comparison purposes after @class is sorted. $class1 = $class[0]; $class2 = $class[1]; $class3 = $class[2]; $class4 = $class[3]; $class5 = $class[4]; $class6 = $class[5]; #Sorts class array and stores the largest value in $result @class_sorted = sort{$a <=> $b} @class; $result = $class_sorted[5]; #Checks if the largest class value is equal to each class. It does this sequentially, so that the first class that matches the value is selected. #Therefore, if a participant repsonds equally for classes 1 and 2, the participant will be assigned to class 1 if($result == $class1) { $result_header = "Chemical Kitten!"; $result_text = "Kapitan, there was an accident in the research facility! It’s imperative we reach the acid baths..."; $result_image = "Chemical Kitten"; $final_class = "1"; } elsif($result == $class2) { $result_header = "Old n' Salty Kitten"; $result_text = "Yes child, enjoy your naive appreciation of life’s novelty. Soon you will grow and so will your disdain for this banal existence you once considered beautiful."; $result_image = "Old n Salty Kitten"; $final_class = "2"; } elsif($result == $class3) { $result_header = "Kaboom Kitten!"; $result_text = "You will now join me in oblivion."; $result_image = "Kaboom Kitten"; $final_class = "3"; } elsif($result == $class4) { $result_header = "Alarm Kitten!"; $result_text = "Alarm!! Don your masks or you will dance the sarin jig this night!!!"; $result_image = "Alarm Kitten"; $final_class = "4"; } elsif($result == $class5) { $result_header = "Bear Kitten!"; $result_text = "I have bested my brethren this day!!!
It is I who will inflict happiness and joy upon countless children in the Moscow Circus!"; $result_image = "Bear Kitten"; $final_class = "5"; } elsif($result == $class6) { $result_header = "Mail Order Kitten!"; $result_text = "You are to make a fine wife for uncouth American businessman!"; $result_image = "Mail Order Kitten"; $final_class = "6"; } #Print data to file open(INFO, ">>$ENV{'DOCUMENT_ROOT_OLD'}/www/heplerlabs.com/P593/homework_3.txt"); print INFO "$date1,$date2,$v01,$v02,$v03,$v04,$v05,$v06,$v07,$final_class,endline\n"; close(INFO); open(INFO, "$ENV{'DOCUMENT_ROOT_OLD'}/www/heplerlabs.com/P593/homework_3.txt"); @data = ; close(INFO); #Provides feedback to participant print "
You are $result_header

$result_image
$result_text


"; print "See how your results compare to others who have taken the quiz!

"; #Calculates count and percentage for each class based on all previous participants $total_count = 0; $class1_count = 0; $class2_count = 0; $class3_count = 0; $class4_count = 0; $class5_count = 0; $class6_count = 0; foreach $row (@data) { #($adate1,$adate2,$av01,$av02,$av03,$av04,$av05,$av06,$av07,$afinal_class,$aendline) @participant = split(/,/,$row); $total_count = $total_count + 1; if ($participant[9] == 1) { $class1_count = $class1_count + 1; } elsif ($participant[9] == 2) { $class2_count = $class2_count + 1; } elsif ($participant[9] == 3) { $class3_count = $class3_count + 1; } elsif ($participant[9] == 4) { $class4_count = $class4_count + 1; } elsif ($participant[9] == 5) { $class5_count = $class5_count + 1; } elsif ($participant[9] == 6) { $class6_count = $class6_count + 1; } } $class1_percent = sprintf("%.0f",(100*$class1_count/$total_count)); $class2_percent = sprintf("%.0f",(100*$class2_count/$total_count)); $class3_percent = sprintf("%.0f",(100*$class3_count/$total_count)); $class4_percent = sprintf("%.0f",(100*$class4_count/$total_count)); $class5_percent = sprintf("%.0f",(100*$class5_count/$total_count)); $class6_percent = sprintf("%.0f",(100*$class6_count/$total_count)); #Outputs a table of the count and percent information calculated above print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Rolcat
Number of Brethren
Percent of the Motherland's population
Chemical Kitten
$class1_count
$class1_percent %
Old n' Salty Kitten
$class2_count
$class2_percent %
Kaboom Kitten
$class3_count
$class3_percent %
Alarm Kitten
$class4_count
$class4_percent %
Bear Kitten
$class5_count
$class5_percent %
Mail Order Kitten
$class6_count
$class6_percent %



"; print "See all the possible results!

"; print "Return to Hepler Labs\n"; print $query->end_html; } if($pass == 0) { print "
Which Rolcat are you?
Take this short quiz to find out which Rolcat (Soviet-era lolcat) you are!

Rolcat Intro
Drat, thwarted so close to freedom’s sweet caress...
I dreamed for but a taste of the decadent west, and now my eulogy is sung by guard dogs and alarm bells.


1. Which term describes you best?

Tricksy.
Disenchanted.
Crazed.
Anxious.
Glorious.
Hot.



2. What is your dream job?

A job? Don’t joke like that.
Mass destruction.
Work is meaningless. I shall toil until I die.
Ninja assassin. Maybe pirate.
Insurance salesman.
Gold medal ice skater.



3. How do you feel about technology?

Children no longer appreciate traditional pleasures. My purpose in life is to rectify this injustice.
I know not of technology, but may in my new future.
Technology allows me to fortify the Republic.
It is a trivial plaything for those lost in worldly distractions.
Anything that allows me to eradicate the capitalists more efficiently is well-valued.
Don it now! Prepare!



4. What is your attitude toward the capitalists?

Capitalists?! Where?? Prepare yourselves, brothers!
Though my wages would be higher with the capitalists, my existence would be meaningless.
I shall be with them soon.
I strive to eradicate them as efficiently as possible.
They are as any other creature, clinging to their meaningless existence till the end.
The ones I have vanquished warm my thoughts at night.



5. What keeps you awake at night?

The fact that capitalists still roam the lands.
Fear. Panic. Horrible nightmare visions.
Practice – perfection is not only desirable, but mandatory.
The thought of a life of solitude and poverty.
Some inevitable but justified side-effect of my profession.
The deep despair that accompanies a realization of how meaningless this life is.



6. The republic is in trouble! What do you do?

Though unfortunate, this does not move me. As you grow, so too will your indifference with this world.
Take the capitalist swine down with us.
Sound the alarm bells. The Republic shall not fail for want of foresight.
DANCE! DANCE FOR THE MASSES.
Flee the Republic! My destiny and I lie elsewhere...
I have prepared the defenses. Enemies that breach the Republic’s border shall not last long.



7. The Republic has found you guilty and sentenced you to death. What was your crime?

Accidentally setting off a chain of events that led to the deaths of 1 million countrymen.
Lack of industry and patriotism.
Too few capitalist kills.
Stockpiling goods for an emergency.
Receiving a score of 9.9.
Attempting to flee the motherland.



" } print $query->end_html;