My long script

2012-09-15 Thread jmrhide-perl
As requested, I ran perltidy on my script to see if I could make it easier for somebody else to read. Perhaps a little explanation of how it works would also be helpful: Tutorial.cgi is triggered by a user who wishes to enlarge his/her vocabulary of technical terms in a certain field. The

My Long Script (1)

2012-09-15 Thread jmrhide-perl
#!/usr/local/bin/perl # use warnings; # use strict; # use diagnostics; use CGI; my $cgi = new CGI; my ( $topic, $score, $lastnum, $answer, $anum, $bnum, $cnum, $dnum, $enum,$smarts, $playlevel, $c_topic, $c_smarts, $c_playlevel, $c_score, $

My Long Script (2)

2012-09-15 Thread jmrhide-perl
# PRINT RESPONSE: $c_topic = $cgi->cookie( -name=> 'topic', -value => $topic, -expires => '+1d', -path=> '/' ); $c_score = $cgi->cookie( -name=> 'score', -value => $score, -expires => '+1d', -path

Re: My long script

2012-09-15 Thread Jim Gibson
On Sep 15, 2012, at 2:46 PM, jmrhide-p...@yahoo.com wrote: > As requested, I ran perltidy on my script to see if I could make it easier > for > somebody else to read. Perhaps a little explanation of how it works would > also > be helpful: [explanation snipped] > To avoid repetition of pr

Re: My long script

2012-09-15 Thread Jim Gibson
Please use the list for postings. That way, everybody gets to see your post. I am responding via the list. On Sep 15, 2012, at 4:49 PM, jmrhide-p...@yahoo.com wrote: > OK, interesting supposition that needs to be tested. I could just replace > every while (1) with a for (1..10) as insurance, bu

Re: My long script

2012-09-15 Thread jmrhide-perl
t_die_handler(\&handle_errors); 14. } It would be WONDERFUL to get an email every time it glitched! Does anybody have a sub written for that? John M Rathbun MD From: Jim Gibson To: Perl Beginners Sent: Sat, September 15, 2012 9:00:35

Re: My long script

2012-09-15 Thread Robert Wohlfarth
On Sat, Sep 15, 2012 at 4:46 PM, wrote: > The user clicks on a button ("A" or "B"), which fires back a string that > reawakens the script and shows it what answer the user chose. The script > inspects the cooky-jar to determine the state of the script, compares the > user's selection with its

Re: My long script

2012-09-15 Thread Jim Gibson
On Sep 15, 2012, at 8:25 PM, jmrhide-p...@yahoo.com wrote: > It would be WONDERFUL to get an email every time it glitched! Does anybody > have > a sub written for that? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands,

Re: My long script

2012-09-16 Thread Paul Anderson
On 2012-09-15, at 11:25 PM, jmrhide-p...@yahoo.com wrote: > It would be WONDERFUL to get an email every time it glitched! Does anybody > have > a > > > sub written for that? Just bear in mind that you need to add logic to the while(1) loops to determine that they are running too long. If it

Re: My long script

2012-09-16 Thread Rob Dixon
On 16/09/2012 05:03, Robert Wohlfarth wrote: On Sat, Sep 15, 2012 at 4:46 PM, wrote: The user clicks on a button ("A" or "B"), which fires back a string that reawakens the script and shows it what answer the user chose. The script inspects the cooky-jar to determine the state of the script,

Proposed correction for my long script

2012-09-16 Thread jmrhide-perl
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...@the

Re: Proposed correction for my long script

2012-09-16 Thread Peter Scott
On Sun, 16 Sep 2012 12:46:08 -0700, jmrhide-perl wrote: > Does it look OK? This is a prime example of something that a test harness would be very useful for, then we'd all know the answer. There may be some entirely different reason why your provider thinks this script is consuming excessive re

Re: Proposed correction for my long script

2012-09-16 Thread Uri Guttman
On 09/16/2012 03:46 PM, jmrhide-p...@yahoo.com wrote: OK, here's my amateurish attempt at a correction: i know you said you don't want to learn to be a professional coder. but there are so many ways to improve your code little by little. most here have been shying away for good reason and bec

Fw: Proposed correction for my long script

2012-09-16 Thread jmrhide-perl
n the snippets of code below? John M Rathbun MD - Forwarded Message From: "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

Re: Fw: Proposed correction for my long script

2012-09-16 Thread Uri Guttman
On 09/16/2012 07:40 PM, jmrhide-p...@yahoo.com wrote: 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 a

Re: Fw: Proposed correction for my long script

2012-09-16 Thread jmrhide-perl
to these looping structures that recur throughout the process of constructing new questions John M Rathbun MD From: Uri Guttman To: beginners@perl.org Sent: Sun, September 16, 2012 8:10:50 PM Subject: Re: Fw: Proposed correction for my long script On 09/16/2012 07:40

Re: Fw: Proposed correction for my long script

2012-09-16 Thread Uri Guttman
On 09/16/2012 09:34 PM, jmrhide-p...@yahoo.com wrote: I copied what was on the manpage for CGI::carp I lost my way on that one, but I don't see how a shuffle works here either. I'm trying to ensure that the program will not pick the same term twice in a row. $lastnum comes from a cookie and re