I am a Perl newbie. I have a website (zggames.com). It has been running fine until now. I got an e-mail from my host today saying:
gmstrnk.pl was disabled today for following reasons: continuous process running (when found it had been running for 76 minu +tes) system processor utilization in excess of 90% This script was locked for over an hour as stated above and jeopardizi +ng other resources on the server. There is a problem with this script + that needs to be addressed before re-activating.
Gmstrnk looks like this:
#!/usr/local/bin/perl # sets a page's rank and returns a thank you message $aflag = 0; $myquery = $ENV{'QUERY_STRING'}; ($myvote,$mygametitle,$mybegin,$myend,$bypasscache) = split(/\&/,$myqu +ery); $mygametitle =~ tr/\+/ /; $mylink =~ tr/\~/\'/; if ($mybegin == 0) { $dbnumber = "1"; } if ($mybegin != 0) { $dbnumber = "2"; } open(FORLOCK,"gmlock.pl") or dienice("Rank set script could not open l +ock file: $!"); flock(FORLOCK, 2) or dienice("Rank set script could not gain exclusive + lock on database: $!"); open(INF,"gmlist" . $dbnumber . ".pl") or dienice("Rank set script cou +ld not open proper game database for reading: $!"); @ary = <INF>; close(INF); $i = -1; $gamenumber = -1; if ($mybegin != 0) { $i = $mybegin - 2; } while ($gamenumber == -1) { $i++; $line = @ary[$i]; chomp($line); ($gmtitle,$gmdescription,$gmurl,$totalvalue,$totalvotes,$averagevo +te,$clicks,$visibility,$siteid,$timesince,$lastip) = split(/\|/,$line +); if ($gmtitle eq $mygametitle) { $gamenumber = $i; } } $line = @ary[$gamenumber]; chomp($line); ($gmtitle,$gmdescription,$gmurl,$totalvalue,$totalvotes,$averagevote,$ +clicks,$visibility,$siteid,$timesince,$lastip) = split(/\|/,$line); if ($lastip ne $ENV{'REMOTE_ADDR'}) { $totalvalue = $totalvalue + $myvote; $totalvotes++; $averagevote = $totalvalue / $totalvotes; $myavg = $averagevote; } $lastip = $ENV{'REMOTE_ADDR'}; if (($dbnumber == 1) && ($totalvotes > 2)) { @ary[$gamenumber] = ""; open(OUTF,">gmlist" . $dbnumber . ".pl") or dienice("Rank set scri +pt could not re-open proper database for writing: $!"); print OUTF @ary; close(OUTF); $dbnumber = 2; open(INF2,"gmlist" . $dbnumber . ".pl") or dienice("Rank set scrip +t could not open proper game database for reading: $!");; @ary = <INF2>; close(INF2); push(@ary,"this text will be replaced\n"); $gamenumber = $#ary; $aflag = 1; } @ary[$gamenumber] = "$gmtitle|$gmdescription|$gmurl|$totalvalue|$total +votes|$averagevote|$clicks|$visibility|$siteid|$timesince|$lastip\n"; if ($aflag == 1) { # if the game is switching databases if ($gamenumber != 0) { $exitflag = -1; $i = $gamenumber; while ($exitflag == -1) { $i--; $line = @ary[$i]; chomp($line); ($gmtitle,$gmdescription,$gmurl,$totalvalue,$totalvotes,$a +veragevote,$clicks,$visibility,$siteid,$timesince,$lastip) = split(/\ +|/,$line); if ($myavg >= $averagevote) { $holder = @ary[$i]; @ary[$i] = @ary[$gamenumber]; @ary[$gamenumber] = $holder; $gamenumber--; } else { $exitflag = 2; } if ($i == 0) { $exitflag = 2; } } } } else { if ($myvote >= $myavg) { if ($gamenumber != 0) { $exitflag = -1; $i = $gamenumber; while ($exitflag == -1) { $i--; $line = @ary[$i]; chomp($line); ($gmtitle,$gmdescription,$gmurl,$totalvalue,$totalvote +s,$averagevote,$clicks,$visibility,$siteid,$timesince,$lastip) = spli +t(/\|/,$line); if ($myavg >= $averagevote) { $holder = @ary[$i]; @ary[$i] = @ary[$gamenumber]; @ary[$gamenumber] = $holder; $gamenumber--; } else { $exitflag = 2; } if ($i == 0) { $exitflag = 2; } } } } else { $exitflag = -1; $i = $gamenumber; while ($exitflag == -1) { $i++; $line = @ary[$i]; chomp($line); ($gmtitle,$gmdescription,$gmurl,$totalvalue,$totalvotes,$a +veragevote,$clicks,$visibility,$siteid,$timesince,$lastip) = split(/\ +|/,$line); if ($myavg < $averagevote) { $holder = @ary[$i]; @ary[$i] = @ary[$gamenumber]; @ary[$gamenumber] = $holder; $gamenumber++; } else { $exitflag = 2; } if ($i == $#ary) { $exitflag = 2; } } } } open(OUTF2,">gmlist" . $dbnumber . ".pl") or dienice("Rank set script +could not re-open proper database for writing: $!"); print OUTF2 @ary; close(OUTF2); close(FORLOCK); print <<END_of_Multiline_Text; Content-type: text/html <html> <head> <title>ZG Games</title> </head> <body bgcolor="#000000" text="#C0C0C0" link="#00FFFF" vlink="#00FFFF" alink="#0000FF"> <p><font size="2" face="Verdana"><strong>Thanks! When you are done playing the game, click END_of_Multiline_Text if ($mybegin == 0) { print "<a href=\"gmnew.pl\" target=\"_top\">here</a>"; } if ($mybegin != 0) { print "<a href=\"gmlist.pl\?$mybegin\-$myend\" target=\"_top\">her +e</a>"; } print <<END_of_Multiline_Text; to go back.</strong></font></p> </body> </html> END_of_Multiline_Text sub dienice { my($msg) = @_; print "Content-type: text/html\n\n"; print "<h2>Error</h2>\n"; print "<p>" . $msg . "</p>\n"; print "<p>Please e-mail this error and the current time to \"rjahr +man\@aol.com\" (no quotes).</p>\n"; exit; }
What's wrong? (Thanks!)

Fixed title per owner's request - dvergin 2002-06-10
Edit kudra, 2002-06-11 Added readmore tag


In reply to Why Did This Stall the Server by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.