title: perl Tie::File to remove lines in text file
body: <p>I have the following code to remove lines out of a text file I am using. However, it is not actually removing the lines I want. I have done a lot of testing here and confirmed that it will remove the lines if I get the line number right. However, the <code>$.</code> seems to be duplicating the actual line number (as when I print on it, it says there are double the number of lines there actually are!)</p>
  
  <pre><code>#!/usr/bin/perl
  # find_company_codes.pl
  
  use strict;
  use warnings;
  use diagnostics;
  
  use Tie::File;
  
  my $split_file = "//server/folder/splits_table.txt";
  
  # remove fields where only MAS has rollcall
  my @file;
  my @lines;
  
  tie @file, 'Tie::File', $split_file or die $_;
  
  foreach (@file) {
  
      @lines = split(",",$_);
  
      next if $lines[0] eq "ESDB Link Processing Reg-Prd-CCD";
      next if $lines[2] ne "";
      next if $lines[3] ne "";
      next if $lines[4] ne "";
      next if $lines[5] ne "";
      next if $lines[6] ne "";
  
      splice(@file, $.,1);
  
  }
  
  untie @file;
  </code></pre>
  
  <p>p.s. - I know I can use <a href="http://perldoc.perl.org/perlfaq5.html#How-do-I-change%2c-delete%2c-or-insert-a-line-in-a-file%2c-or-append-to-the-beginning-of-a-file%3f" rel="nofollow">this</a>, however, I thought using 'Tie::File` would be a little more straight to the point in this case.</p>