title: Perl - Why does shift lose its value after being used?
body: <p>This code works - It takes an array of full txt file paths and strips them so that when <code>$exam_nums[$x]</code> is called, it returns the file name</p>
  
  <pre><code>for (0..$#exam_nums)
  {
   $exam_nums[$_] =~ s/\.txt$//; #remove extension
   $exam_nums[$_] =~ s/$dir//g; #remove path
  }
  </code></pre>
  
  <p>When I try to do this for a single variable, it doesn't work.  I'm calling a subroutine and sending it a present, but the variable is empty at the end.  (It is getting into the if statement block, because the other lines in there run fine.)  Here's the code:</p>
  
  <p>Call to the sub:</p>
  
  <pre><code>notify($_);
  </code></pre>
  
  <p>The <code>$_</code> is from a <code>foreach(@files)</code> loop that works</p>
  
  <p>The sub:</p>
  
  <pre><code>sub notify
  {
   if(shift)
   { 
    $ex_num = shift;
    $ex_num =~ s/\.txt$//; #remove extension
    $ex_num =~ s/$dir//g; #remove path
          print $ex_num;
          print "\nanything";
   }
  }
  </code></pre>
  
  <p>I tried taking out the <code>$</code> in the "remove extension" portion of the regex, but that didn't help.</p>