Is there a way to restart LWP::Simple or make it load faster?
use LWP::Simple; $ipaddress2 = get ('http://www.domain.com/ip-address.txt'); $number = get ('http://www.domain.com/counter.txt');
makes the script take about 15 seconds to load vs less than a second with out it. Yet on another domain on the same server, it doesn't slow it down.
#!/usr/bin/perl use LWP::Simple; $ipaddressmain2main = get ('http://www.domain.com/ip-address.txt'); $numbermain = get ('http://www.domain.com/counter.txt'); $ipaddressmain = "/home/site1337/public_html/ip-address.txt"; $countermain = "/home/site1337/public_html/counter.txt"; $database = "/home/site1337/public_html/logs.shtml"; { open(numbermain,"$countermain"); $num = <numbermain>; close(numbermain); if ($ipaddressmain2main == $ENV{'REMOTE_ADDR'}) { $num; } else { $n +um++; } open(NEWFILE,">$ipaddressmain") || die $!; print NEWFILE "$ENV{'REMOTE_ADDR'}\n"; close(NEWFILE); open(NUM,">$countermain") || die $!; print NUM "$num"; close(NUM); } $shortdate = `date +"%D %T %Z"`; chop ($shortdate); open (DATABASE,">>$database"); print DATABASE "$ENV{'REMOTE_ADDR'} - $shortdate - $ENV{'HTTP_ +USER_AGENT'} - <A HREF=\"http://$ENV{'HTTP_HOST'}$ENV{'REQUEST_URI'}\ +">http://$ENV{'HTTP_HOST'}$ENV{'REQUEST_URI'}</a> - <A HREF=\"$ENV{'H +TTP_REFERER'}\">$ENV{'HTTP_REFERER'}</a>\n"; close(DATABASE); $page = $in{'page'}; if ($page eq 'XXXXXXX') { print "Content-type: text/html\n\n"; print <<EOM; EOM } elsif ($page eq 'XXXXX') { print <<EOM; EOM } else { use LWP::Simple; $ipaddress2 = get ("http://www.domain.com/stats/$page/ip-address.txt") +; $number = get ("http://www.domain.com/stats/$page/counter.txt"); $ipaddress = "/home/site1337/public_html/stats/$page/ip-address.txt"; $counter = "/home/site1337/public_html/stats/$page/counter.txt"; { open(NUMBER,"$counter"); $num = <NUMBER>; close(NUMBER); if ($ipaddress2 == $ENV{'REMOTE_ADDR'}) { $num; } else { $num++; } open(NEWFILE,">$ipaddress") || die $!; print NEWFILE "$ENV{'REMOTE_ADDR'}\n"; close(NEWFILE); open(NUM,">$counter") || die $!; print NUM "$num"; close(NUM); } print "Content-type: text/html\n\n"; print <<EOM; PAGE CONTENT EOM exit; }

In reply to use LWP::Simple slows script down. by Jesse Smith

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.