Argument isn't numeric

2012-06-10 Thread jmrhide-perl
Hello and thanks for volunteering your time! I'm returning to PERL after about a year and am struggling to remaster some syntax: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; # Converts current directory to a list of links my @dir; my $name; my $i = 0; opendir

My script is OUT OF CONTROL!

2012-09-13 Thread jmrhide-perl
Hi, and thanks for volunteering to help! I installed the following script last year and it seemed to be working fine. Yesterday, however, my hosting service took down my site because the script was tying up so much of their server resources that it was a threat to their business. One of the fo

Clarification re Perl Script out of control

2012-09-13 Thread jmrhide-perl
I can see from the responses so far that I was unclear in the way I phrased my question, so please let me emphasize the following: MY SCRIPT, THOUGH COMPLEX (500 LINES), PRODUCES EXACTLY THE OUTPUT I EXPECT EVERY TIME I RUN IT. In particular, it never hangs or gives a wrong answer. Also, with al

My script is...

2012-09-14 Thread jmrhide-perl
I appreciate the helpful input. It appears from my server stats that the script in question has only run a couple of times a day on average, so that's fewer than a thousand instances in the past year. I ran LOTS of tests of the script, none of which hung or produced unexpected output. If the

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 jmrhide-perl
Sorry about that. I hit reply and didn't notice it had your address in there rather than the list's. Since I've never seen this program hang, I want to be notified any time it hangs, no matter who the user is. I found two options in the perldoc for CGI::Carp -- 1.BEGIN { 2.

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

Fw: Proposed correction for my long script

2012-09-16 Thread jmrhide-perl
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 snipp

Re: Fw: Proposed correction for my long script

2012-09-16 Thread jmrhide-perl
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 refers to the previous question. What about for (my $lo

Proposed correction

2012-09-16 Thread jmrhide-perl
for (my $loopiter = 0; $loopiter < $loopmax; $loopiter++) { #1 if ($loopiter >= ($loopmax - 1)) { die "Loop number $loopnum has iterated $loopiter times" } $termnum[0] = int( rand($defnum) ); last unless ( $termnum[0] == $lastnum ); }

Re: Proposed correction

2012-09-17 Thread jmrhide-perl
So assuming I write for my $loopiter (0 .. $loopmax) { #1 if ($loopiter >= ($loopmax - 1)) { die "Loop number $loopnum has iterated $loopiter times" } $termnum[0] = int( rand($defnum) ); last unless ( $termnum[0] == $lastnum ); } $loo

Re: Proposed correction

2012-09-17 Thread jmrhide-perl
<> I LIKE IT! While brewing tea, it occurred to me to speculate on how a mischievous person would go about killing this script. The one thing that occurred to me is that you could invoke the script with a nonsense value like CATEGORY=bubububu. That would lead to an empty set of terms with insc