Hi John,

[EMAIL PROTECTED] (John Buwa) wrote:
>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.

You really have to turn on 'use strict'.  It looks like both $i and
$line are undeclared variables.  Also, why do you chomp($line) and then
put the newline back on?  You should just leave it as it is.

Also, you don't lock MYFILE when you read it, so you could be reading
garbage input.


>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
>
>

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  [EMAIL PROTECTED]                            The Math Forum

Reply via email to