Kozz has asked for the wisdom of the Perl Monks concerning the following question:
I just need a few more eyes to look at this code and help me determine just what in the world could possibly be going wrong here. this is a CGI script, by the way.
What might be happening here? The first flock call to the DBA filehandle works just fine. I'm pulling my hair out after staring at this code for over an hour now. Please help.
*sobs*
Of course, this is only a small piece of a MUCH larger script I've already written. I'm opening a datafile and comparing it to some user input, and then opening a tempfile to write any lines that should be preserved from DBA. Then I'd rewind both files and write from TMPA to DBA and then truncate, and close. Anyhow, the real problem comes in when I try to flock the temp file. I've put debugging lines in the code with messages that say things like "I've got this far" or whatever, after each line. And it gets all the way up to that flock call to the TMPA filehandle just fine. But if I let the script try to execute that line, the browser just sits there and hangs... like it's in a loop or something.my $tempfile="/tmp/$$.tmp"; open(DBA, "+< $datafile") or die "Could not read $datafile: $!"; flock(DBA, 2); seek(DBA, 0, 0); open(TMPA, "+> $tempfile") or die "Could not open tempfile: $!"; flock(TMPA, 2) or die "ERROR: $!"; # it dies here? seek(TMPA, 0, 0); while(<DBA>){ # more code here, etc etc ...
What might be happening here? The first flock call to the DBA filehandle works just fine. I'm pulling my hair out after staring at this code for over an hour now. Please help.
*sobs*
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: More Eyes
by tye (Sage) on Aug 22, 2000 at 07:36 UTC | |
by Kozz (Friar) on Aug 22, 2000 at 08:52 UTC | |
by Jonathan (Curate) on Aug 22, 2000 at 13:56 UTC | |
Re: More Eyes
by merlyn (Sage) on Aug 22, 2000 at 15:36 UTC | |
by tilly (Archbishop) on Aug 22, 2000 at 15:41 UTC | |
Re(tilly) 1: More Eyes
by tilly (Archbishop) on Aug 22, 2000 at 06:14 UTC | |
I must thank you all, and deeply apologize
by Kozz (Friar) on Aug 22, 2000 at 19:05 UTC | |
RE: More Eyes, Please
by turnstep (Parson) on Aug 22, 2000 at 18:03 UTC |
Back to
Seekers of Perl Wisdom