Hello,
 
I am trying to finish up my scripts conversion to mod perl and here is a routine i truely do not undestand why it is not working. This is the same code that is running on both the modperl i am useing to port scripts and test and the live non-modperl apache, which works fine:
 
This is a routine that deletes a line from a mail file stored in this format:
 
|user|date|time|message|status|
 
If the file is say 20 lines and i am removing line 5, defined by $msgnum, it is suposed to remove only line 5 and print the rest back to the users mail file. The same code on the production machine works fine. I have experienced some really strange behavior of which none is correct on the modperl. Either it will remove multiple lines from the mail file along with the line it was suposed to OR it will remove the entire mail file and sometime later a portion of the mail file will re-apear garbled? Could this possibly have something to do with the flock files? I am using:
 
use Fcntl ':flock'; # import LOCK_* constants
 
in all my scripts, is this still valid in modperl servers?
 
if (($user_matched == 1) && ($pass_matched == 1)) {
                $i = 1; #init count variable
                open(MYFILE, "mail/$user"); #open users mail box to read in
                @OLDMAIL = <MYFILE>;
                close(MYFILE);
                open(NEW, ">mail/$user"); #open new copy of users mail box
                flock (NEW, LOCK_SH);
                seek (NEW, 0, 0);     # Rewind
                foreach $line (@OLDMAIL) {
                        chomp($line);
                        unless ($i == $msgnum) {
                                print NEW "$line\n";
                                                            }
                                $i++ #increment cnt
                                                       }#End of foreach loop
                flock (NEW, LOCK_UN);#release flock
                close(NEW);#close new mail file
                                                                             }#end of it
 
 

Reply via email to