Hi i have a sub that takes like 30 secs to run but i dont know why i have used the same sub in other cgi's and it runs instantly but this code takes ages i dont know why? code below:-
Code:
#!/Perl/bin/perl
use CGI;
################################################################################
if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
else
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
################################################################################
$loginname = $FORM{login_name};
$playeremail = $FORM{player_email};
$playerchar = $FORM{player_character};
$loginpass = $FORM{login_password};
$loginlist ="REMOVED FOR SESATIVITY";
$forward = "../usermng.html";
############################# Check Fields #####################################
if ($loginname eq "") {
&error("a Login Name");
}
if ($playeremail eq "") {
&error("an email address");
}
if ($playerchar eq "") {
&error("a Player Character");
}
if ($loginpass eq "") {
&error("a Player Password");
}
unless ($playeremail =~ m/\@/i) {
&error("correct e-mail address");
}
############################ Write Info To File ###############################
if (($loginname ne "") && ($loginpass ne "")) {
open(FILE, ">>$loginlist");
print FILE "$loginname\|$loginpass\|$playerchar\|$playeremail\n";
close(FILE);
print <<"htmlend";
print "<html><head><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=$forward\"></head></html>\n";
print "<a href=\"$forward\">Click here to contine!</a>\n";
htmlend
}
############################# Sub Programmes ###################################
sub error {
local($error) = $_[0];
print <<"html";
<html>
<head><title>Error</title></head>
<body>
<center><font size=5>Error</font><p><b>You must enter $error!</center>
</body>
</html>
html
exit;
}