title: Perl IF statement not matching variables in REGEX
body: <pre><code>my $pointer = 0;
  foreach (@new1)
  {
         my $test = $_;
         foreach (@chk)
         {
                 my $check = $_;
                 chomp $check;
                 delete($new1[$pointer]) if ($test =~ /^$check/i);
         }
         $pointer++;
  }
  </code></pre>
  
  <p>The if statement never matches the fact that many entries in the @new1 array do contain $check at the start of the array element (88 at least).
  I am not sure it is the nested loop that is causing the problem because if i try this it also fails to match:</p>
  
  <pre><code>foreach (@chk)
  {
          @final = (grep /^$_/, @new1);
  }
  </code></pre>
  
  <p>@final is empty but I know at least 88 entires for $_ are in @new1.</p>
  
  <p>I wrote this code on a machine running Windows ActivePerl 5.14.2 and the top code works. I then (using a copy of @new1) compare the two and remove any duplicates (also works on 5.14.2). I did try to negate the if match but that seemed to wipe out the @new1 array (so that I didn't need to do a hash compare).</p>
  
  <p>When I try to run this code on a Linux RedHat box with Perl 5.8.0 it seems to struggle with the variable matching in the REGEX. If I hard code the REGEX with an example I know is in @new1 the match works and in the first code the entry is deleted (in the second one value is inserted in @final).</p>
  
  <p>The @chk array is a listing file on the web server and the @new1 array is created by opening two log files on the web server and then pushing one into the other.</p>
  
  <p>I had even gone to the trouble of printing out $test and $check in each loop iteration and manually checking to see if any of the the values did match and some of them do.</p>
  
  <p>It has had me baffled for days now and I have had to throw the towel in and ask for help, any ideas?</p>