AARGH SOMEONE HELP!
sub UpdateCharHtml
{ local $key, $value;
opendir(CHARS, "users/$username/");
local @charinfos=readdir(CHARS);
close(CHARS);
@charinfos=grep(/\.charinfo$/, @charinfos);
open(CHARHTML, ">users/$username/chardata.htm");
print CHARHTML &CharHtmlTop;
foreach $filename(@charinfos)
{ open(TEMPFILE, "users/$username/$filename") | | &CgiDie("Cant open users/$username/$filename");
print "\n$filename\n";
while(<TEMPFILE> )
{ ($key,$value)=split(/\t/, $_);
chomp($value);
$tempCharData{$key} = $value;
}
close(TEMPFILE);
print CHARHTML &CharHtmlDebug;
}
print CHARHTML &CharHtmlBot;
close CHARHTML;
}
########################################
sub CharHtmlDebug
{
local @data=keys %tempCharData;
foreach(@data)
{ print "$_ - $tempCharData{$_}\n";
delete($tempCharData{$_});
}
}
###################################
there are two files in the directory. this prints:
filename1.charinfo
filename1s key-value pairs
...
...
...
...
...
filename2.charinfo
#and thats it. the key-value pairs of file2 dont get printed. the while(<TEMPFILE> ) loop is never executed the second time.
ive spent hours on this, im gonna scream
someone help please!!!
ROB posted this at 04:13 — 6th March 2000.
They have: 447 posts
Joined: Oct 1999
well, to save other people the hell ive went through ill post the solution.
about 10 hours later i found the problem.
the file TEMPFILE was opened by a previous subroutine but not closed, therefore, while(<TEMPFILE> ) didnt execute because eof had already been reached.
*hits himself in the head*
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.