Re: Corrupted Data

Jimstone77_at_aol.com
Date: 10/30/03


Date: Thu, 30 Oct 2003 10:51:13 EST
To: beginners@perl.org

In a message dated 10/30/03 10:35:08 AM Eastern Standard Time, peter@PSDT.com
writes:

> ]
>
> Why don't you post the actual code since this obviously isn't it...

     $old = "oldfile.txt";
     $new = "newfile.txt";

     open(OLD,"$old") or die "Can't Open File: $!";
        flock OLD, 2;
      open(NEW,>$new) or die "Can't Open File: $!";
         flock NEW, 2;
       while (<OLD>) {
          if ($_ =~ /NO_EMAIL/) {
           $count++;
          }
          else {
              print NEW $_;
          }
       }
     close(NEW) or die "Can't Close File: $!";
    close(OLD) or die "Can't Close Old: $!";
   rename($old,$new);

  Is there something inherently wrong with doing it this way?