title: How to get rid of use of an uninitialized value within an 'if' construct using a Perl regex
body: <p>How do I get rid of use of an uninitialized value within an <code>if</code> construct using a Perl regex?</p>
  
  <p>When using the code below, I get use of uninitialized value messages.</p>
  
  <pre><code>     if($arrayOld[$i] =~ /-(.*)/ || $arrayOld[$i] =~ /\#(.*)/)
  </code></pre>
  
  <p>When using the code below, I get no output.</p>
  
  <pre><code>     if(defined($arrayOld[$i]) =~ /-(.*)/ || defined($arrayOld[$i]) =~ /\#(.*)/)
  </code></pre>
  
  <p>What is the proper way to check if a variable has a value given the code above?</p>