I guess I've been vague again. I was really hoping for somebody to cast an eye on the subroutines I added earlier today. My intention was to (1) prevent any infinite looping and (2) get notification if one of the loops misbehaves. Did I make any obvious logical or grammatical errors in the snippets of code below?
John M Rathbun MD ----- Forwarded Message ---- From: "jmrhide-p...@yahoo.com" <jmrhide-p...@yahoo.com> To: beginners@perl.org Sent: Sun, September 16, 2012 3:46:47 PM Subject: Proposed correction for my long script OK, here's my amateurish attempt at a correction: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; use CGI; my $cgi = new CGI; use Mail::Sendmail; use CGI::carp qw(set_die_handler); BEGIN { sub handle_errors { my $msg = shift; sendmail( From => 'i...@theinfosite.com', To => 'jmrhide-theinfos...@yahoo.com', Subject => 'Tutorial Feedback', Message => $msg, ); } set_die_handler(\&handle_errors); } my ( $topic, $score, $lastnum, $answer, $anum, $bnum, $cnum, $dnum, $enum, $smarts, $playlevel, $c_topic, $c_smarts, $c_playlevel, $c_score, $c_lastnum, $c_goodans, $stimulus, $texta, $textb, $textc, $textd, $texte, $defnum, $smiley, $feedback, $goodans, $restart, @data, @cat, @term, @def, @story, @candidate, @termnum, $sound ); my $instructions = "(Click the button next to the best response)"; my $ops = 0; my $loopnum = 1; my $loopmax = 1000; (Skip to "Next Question") if ( $answer or $restart ) { if ( $playlevel < 1 ) { for (my $loopiter <= $loopmax) { #1 if $loopiter >= $loopmax { die "Loop number $loopnum has iterated $loopiter times" } $termnum[0] = int( rand($defnum) ); last unless ( $termnum[0] == $lastnum ); } $loopnum++; Does it look OK? John M Rathbun MD