<% my $debate = "040930"; $debate = $Request->QueryString("d") if $Request->QueryString("d"); my $source = "debate" . $debate . ".txt"; $source = $Server->MapPath($source); my @debates = (); open IN, "<$source"; while () { chomp; push( @debates, $_ ) } my $phrase = $Request->QueryString("p"); my $speaker = $Request->QueryString("s"); my $filter = $Request->QueryString("f"); my @debates_mark = (); my %scores = (); my $total_score = 0; while (@debates) { my $turn = shift (@debates); my ($speak, $text) = $turn =~ /^([A-Z]+): (.*)$/; $text =~ s!($phrase)!$1!ig if $phrase; if ($speak =~ /kerry|edwards|cheney|bush/io) { my $break = $phrase || " "; my @breaks = split(/$break/i, $text); $total_score += $#breaks; if ($scores{lc($speak)}) { $scores{lc($speak)} += $#breaks; } else { $scores{lc($speak)} = $#breaks; } } $turn = "$speak: $text"; my $use = 1; $use = 0 unless (($speak =~ /$speaker/i) || !$speaker); $use = 0 unless (($text =~ /$phrase/i) || !$phrase); push(@debates_mark, $turn) if $use; } my @speakers = keys %scores; %> Debate Spotter
highlight phrase:   debate:   speaker:   matching statements only: >  
Total: <%= $total_score %> <% foreach my $person (keys %scores) { %> | <%= ucfirst($person) %>: <%= $scores{$person} %> <% } %>
<% foreach my $turn (@debates_mark) { %>

<%= $turn %>

<% } %>