I am just wondering if you can look at this MAIN script I wrote and tell me if you see any issues with it. When I run this script, it seems to be sucking up a LOT of the Server Load. I don't know why it would be doing that, since I do close every process(I THINK). Can you take a look at it for me, and please point out any "bad" Habits I might have picked up? I will not post the entire system as it's pretty big, I'll just post the main index script.
#!/usr/bin/perl -w BEGIN { push (@INC,"/home/username/mods"); push (@INC,"/home/username2/mods"); } use Carp (); local $SIG{__WARN__} = \&Carp::cluck; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard :cgi-lib escapeHTML); use Mail::Sendmail; use Digest::MD5; use Crypt::CBC; use Crypt::Blowfish; use LWP::UserAgent; use Image::Magick; # I really don't use this YET, I should remove it I + guess... Until I need it use SiteDB::Session; ReadParse(\%in); use vars qw($cookie $sess_id $sess_ref $page $is_logged_in %in); $sess_id = cookie("sess_id"); if ($sess_id eq "" && $in{sess_id} ne "") { $sess_id = $in{sess_id}; } $sess_ref = SiteDB::Session->open_with_expiration(undef, $sess_id) if +defined ($sess_id); require "/home/username/site/path/data.conf"; if ((defined($in{pg}) && $in{pg} eq "quit") && defined($sess_ref)) { if ((defined($sess_ref->attr("remember_me")) && $sess_ref->attr("r +emember_me") == 1) && (!defined($in{expire}) || (defined($in{expire}) + && $in{expire} != 1))) { Log_Out_User($sess_ref); } else { Delete_Session_Forever($sess_ref); } } if (!defined ($sess_ref)) { defined ($sess_ref = SiteDB::Session->open (undef, undef)) or error ("Could not create new session: $SiteDB::Session::err +str"); $cookie = cookie (-name => "sess_id", -value => $sess_ref->session_id(), -path => url (-absolute => 1), -expires => "+1y" ); } get_cookie_values($sess_ref); require "/home/username/site/path/config.data"; $sess_ref->expires ($sess_ref->now() + (60*60*24*365)) if !defined ($s +ess_ref->expires()); $Page_Dir = "/home/username/site/path/pages"; $pg = $in{pg}; $enter1 = 0; if (!$pg || !-e "$Page_Dir/$pg.conf") { require "$Page_Dir/enter.conf"; $enter1++; $page .= $page_content; } elsif ($pg =~ /inventory/i) { $item_num = $in{item_num}; require "$Page_Dir/inventory.conf"; if ($item_num eq "") { $page .= show_form(""); } else { $page .= Check_inventory(); } $page .= qq~<table border="0" class="table2" align="center" width +="95%"> <tr valign="top"> <td align="right">Last updated on: <font color="orange">~; open(UPDATE, "/home/username/site/path/stock/updated.conf") or die "Co +uld not get Last Update time: $!"; seek(UPDATE,0,0); while(<UPDATE>) { if ($_ ne "") { $page .= $_; } } close(UPDATE); $page .= qq~</font></td> </tr> </table> ~; } elsif(-e "$Page_Dir/$pg.conf") { $test_cookie2 = cookie ("sess_id"); if (!defined($test_cookie2) || (defined($test_cookie2) && $test_co +okie2 eq "")) { $nocookies = 1; $include_sess_id = "&sess_id=" . $sess_ref->session_id(); } else { $nocookies = 0; $include_sess_id = ""; } $datafile = "$Page_Dir/$pg.conf"; require $datafile; $page .= $page_content; } if ($enter1) { enter_header($title,"",""); } else { top_header("$title","",""); } if ($in{pg} ne "" || $in{pg} ne "enter") { $page .= qq~</td>\n</tr>\n</table> </td>\n</tr>\n</table>~; } $page .= p({-style => "margin-left: 20", -align => "center"}, br() + . qq~<font face="Arial" color="#FFFFFF" size="1">© COPYRIGHT 2002 TH +E GIFT COTTAGE<br />ALL RIGHTS RESERVED<br />Art work by <a href="htt +p://www.thomaskinkade.com/magi/servlet/com.asucon.ebiz.home.web.tk.Ho +meServlet" class="PageLink" target="tom">Thomas Kinkade</a></font>~); print $page, br() x 3, end_html(); # Close page $sess_ref->close($sess_id) if defined($sess_ref);# Close the sessi +on. exit; # Exit system. sub error { my $er_message = shift; $title = "The Gift Cottage - Error Page"; top_header("$title","",""); print h3({-align=>"center"},"Error"), p(strong($er_message)), br(), br(), qq~ </p /> </td /> </tr /> </table /> </td /> </tr /> <tr valign="top"> <td bgcolor="#E1EAF1"> <font size="1"> <div align="center"><font class="copyright">© COPYRIGHT 2002 THE GIFT +COTTAGE<br />ALL RIGHTS RESERVED</font /> </div /> </font /> </td /> </tr /> </table /> ~, p({-style => "margin-left: 20", -align => "center"}, br() . qq~<font f +ace="Arial" color="#FFFFFF" size="1">© COPYRIGHT 2002 THE GIFT COTTAG +E<br />ALL RIGHTS RESERVED</font>~), br() x 4, end_html(); $sess_ref->close($sess_id) if defined($sess_ref);# Close the session. +Used here because exits next! exit; }
If you have any questions, please just let me know. I would really appreciate any advise you have for me.

thx,
Richard

Edit by tye, add READMORE, new title


In reply to Please review script; too much server load by powerhouse

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.