#!/usr/bin/perl # # Programmer: Craig Stuart Sapp # Creation Date: Sat Nov 19 01:16:35 PST 2005 # Last Modified: Sat Nov 19 01:16:35 PST 2005 # Filename: ...mazurka/experiments/tempojnd/countdata # Syntax: perl 5 # # Description: Counts the number of correct answers for each type of gain. # # Input Data line sample: # 20 60 0.015 -1 -1 Y # use strict; my %correct; my %total; my $line; my $ans; my $gain; while ($line = <>) { next if $line =~ /^\!/; next if $line =~ /^\*/; next if $line =~ /^\s*$/; next if $line =~ /^=/; next if $line !~ /^\d/; if ($line =~ /^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)/) { $gain = $3; $ans = $6; $total{$gain} += 1; $correct{$gain} += 1 if $ans =~ /^Y/i; } else { print "ERROR: $line"; } } my @keys = keys %total; @keys = sort bynumber @keys; my $key; my $percent; foreach $key (@keys) { $percent = 1.0 * $correct{$key} / $total{$key}; print "$key\t$percent\t$correct{$key}/$total{$key}\n"; } sub bynumber { return +1 if $a < $b; return -1 if $a > $b; return 0; }