#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; # Randomly select one item from a list of items # Demonstrates random assignment to conditions $pass= $query->param('pass'); $v1= $query->param('v1'); if($pass < 1){ $pass = 0; } print $query->header; print $query->start_html(-title=>'randomization'); print ""; if($pass == 1){ print "Thank you for your response.
"; # save data if desired } if($pass == 0){ # Define the stimuli $cond0= "This applicant received her PhD one year ago from the University of Illinois. Her research is concerned with understanding the cognitive mechanisms underlying individual differences in working memory capacity. She has published four articles in peer-reviewed journals, on two of which she was first author."; $cond1= "This applicant received his PhD one year ago from the University of Illinois. His research is concerned with understanding the cognitive mechanisms underlying individualdifferences in working memory capacity. He has published four articles in peer-reviewed journals, on two of which he was first author."; # randomly select a condition $thisCondition = &randomSelect(0,1); print "
"; # present different stimuli depending on the condition selected if($thisCondition == 0){ print "$cond0"; } else{ print "$cond1"; } print "


How qualified do you think this individual is for the job position?
Not at all qualified Strongly qualified

"; print ""; print ""; print "
"; } print $query->end_html; # ----------------- Subroutines ----------------------------- # for a good tutorial/overview of Perl subroutines, see # http://www.comp.leeds.ac.uk/Perl/subroutines.html #------------------------------------------------------------ sub randomSelect { # this subroutine randomizes the elements of an array and returns the new array srand; my(@new) = (); while (@_){ push(@new, splice(@_, rand @_,1)); } return $new[0]; }