#!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 # in a 2 x 2 design $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){ # randomly select a condition $thisCondition = &randomSelect(0,1,2,3); print "
"; # present different stimuli depending on the condition selected if($thisCondition == 0){ # male low $stimulus= "This applicant received his PhD one year ago from the University of Illinois. His research is concerned with understanding the cognitive mechanisms underlying individual differences in working memory capacity. He has published four articles in peer-reviewed journals, on two of which he was first author."; } if($thisCondition == 1){ # female low $stimulus= "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."; } if($thisCondition == 2){ # male high $stimulus= "This applicant received his PhD one year ago from the University of Illinois. His research is concerned with understanding the cognitive mechanisms underlying individual differences in working memory capacity. He has published eight articles in peer-reviewed journals, on four of which he was first author."; } if($thisCondition == 3){ # female high $stimulus= "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 eight articles in peer-reviewed journals, on four of which she was first author."; } print "
$stimulus

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]; }