Can anyone see the error in this code - I've been racking my brain for hours and can't see it.
perl -c script.cgi produces "Syntax OK" but when I run it I get a 500.
my $username = $IN->param('username');
my $password = $IN->param('password');
@files = grep { /\.txt$/, readdir(DIR); }
closedir(DIR);
if ("$username.txt" eq $_) {
&site_html_track_failure("Sorry, this username exists.") and return;
}
else {
open(FILE,">$dir/$username.txt") || &cgierr("Could not open $dir/$username.txt : $!");
print FILE "$username|$password\n";
close(FILE);
&site_html_track_login("Thankyou, you may now login below.") and return;
}
}
}Help is appreciated - thanks.
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/
perl -c script.cgi produces "Syntax OK" but when I run it I get a 500.
Code:
sub main {Code:
my $dir = "/home/sites/www.domain.com/web/search"; my $username = $IN->param('username');
my $password = $IN->param('password');
Code:
opendir(DIR,"$dir/") || &cgierr("Could not open $dir/ : $!"); @files = grep { /\.txt$/, readdir(DIR); }
closedir(DIR);
Code:
foreach (@files) { if ("$username.txt" eq $_) {
&site_html_track_failure("Sorry, this username exists.") and return;
}
else {
open(FILE,">$dir/$username.txt") || &cgierr("Could not open $dir/$username.txt : $!");
print FILE "$username|$password\n";
close(FILE);
&site_html_track_login("Thankyou, you may now login below.") and return;
}
}
}
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/