Jesse Smith has asked for the wisdom of the Perl Monks concerning the following question:
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.use LWP::Simple; $ipaddress2 = get ('http://www.domain.com/ip-address.txt'); $number = get ('http://www.domain.com/counter.txt');
#!/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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use LWP::Simple slows script down.
by davido (Cardinal) on Feb 10, 2014 at 05:17 UTC | |
by Jesse Smith (Acolyte) on Feb 11, 2014 at 18:14 UTC | |
by davido (Cardinal) on Feb 11, 2014 at 19:07 UTC | |
|
Re: use LWP::Simple slows script down.
by karlgoethebier (Abbot) on Feb 10, 2014 at 11:58 UTC |