PDA

View Full Version : Urgent Perl Help!


burdrumz
05-15-2001, 10:00 PM
I REALLY need to know what these two perl errors mean, and how to fix them:

Bad File Descriptor

and

Numerical result out of range

Both of these are file related. What do they mean?

eric418
05-16-2001, 01:07 AM
i guess it'll be better for you to post the script here. IF they are not too big.

burdrumz
05-16-2001, 03:54 PM
The subroutine &write_file which has the error "Numerical result out of range" is here. Normally, this works, but in some situations, it doesn't.


sub write_file {
if ($ENV{'HTTP_REFERER'} =~ /pages.cgi?index/i) {
} else {
&decpass;
}
open(CHAR, ">../../players/" . $entemail . ".txt") || &doesnt_exist;
flock (CHAR, 2);
print CHAR "$filepassword:$email:$name:$level:$bankmoney:$handmoney:$totstr:$atkstr:$spd:$end:$diamonds:$visits: $days:$housetype:$houserooms:$align:$curhp:$maxhp:$houseguest:$income:$job:$gend:$cores:$sparmember: $chi:$mass:$w:$a:$i:$n:$bp:$win:$loss:$train:$bat:$gymeng:$hopt:$teng:$gd:$td:$strg:$spdg:$endg:$vot e:$cbox:$layout:$union";
flock (CHAR, 8);
close (CHAR);
&encrypt;

}


Now, here's the reset script: in its entirety.. (omitting some subs)


opendir(CHARDIR, "../../players/") || "cant open CHARDIR: $!";
@chardirplayers=readdir(CHARDIR);

foreach $char (@chardirplayers) {
if ($char =~ /\@/) {
open(CHAR, "../../players/" . $char . "") or die "$char no work open: $!";
&split_file;
$days=$days+"1";
$curhp=$maxhp;
$cores="0";
$mass="0";
$gd="0";

&write_file || die "$char write no work: $!";
}
}
open(BAN, ">../../chat/banned.txt");
print BAN "";
close (BAN);

print "Done: $!";

closedir(CHARDIR);


That returns "Bad file Operator" when run by the cron, but by typing in the address, it works.

sylow
05-17-2001, 05:19 AM
use full path when opening file not relative path

burdrumz
05-17-2001, 08:14 PM
Actually, I realized that after posting. I tried it, and it STILL doesnt work. The only thing in @chardirplayers is ".", which is current directory. It says nothing about the other 15 files in it.

HelP!