title: Perl uninitialized value when using alternation in regex
body: <p>I have a for loop with an if statement that looks like this: </p>
  
  <pre><code>   for (my $i=0; $i &lt; $size; $i++) {
         if ($array[$i] =~ m/_(B|P|BC|PM)/) {
             #Remove from @array
             splice(@array, $i, 1);
             next;
         }
         #Get rid of numbers at the end
         $array[$i] =~ s/_[0-9]+//;
     }
  </code></pre>
  
  <p>I am getting an error saying that says "Use of uninitialized value within @array in pattern match...." on the line with the if statement. </p>
  
  <p>When I remove the alternation from the regex on that line, the error goes away. If I comment out the whole if statement, the regex under the comment "#Get rid of numbers at the end" does not produce any errors. </p>
  
  <p>I've printed out all values of @array and everything looks fine. I've tried no parentheses and brackets instead of the parentheses in the expression with no change. Any ideas what could be causing this?</p>