This week we will look at an example of using Perl CGI programs to conduct a simple experiment on the web. The "experiment" consists of 2 questions, presented in one of two versions.
The first Perl script, experiment1.pl, accesses the expdata1 table in the orval Mysql database on the course server to determine the condition (1 or 2) for the current participant. It then accesses the experiment1_stimuli table to get the stimuli to present. It presents the stimuli in an XHTML form. The "action" for the form sends the responses to a second Perl script.
The second Perl script experiment1-storeData.pl then stores the data to the expdata1 table in the database, and displays its contents in an XHTML table.
First run the experiment a couple of times and observe the results as recorded in the table. Be sure to reload the page before submitting data a second time.
1. Copy the two Perl scripts used to run the experient to your cgi-bin directory. Create a table in your database on the course server to store the data in (or use the one you created last week if you wish). Also create a second table and place your experimental stimuli in it (or use last week's). Then edit the Perl scripts to run your experiment and save the data in your database. Place a link to your experiment on your home page on the course server.