title: perl - how do you extract all elements of an array except the last?
body: <p>I need to extract all elements in an array except the last and store them in a scalar for later use.
  At first, I thought this would be possible using array slices, but it appears that you cannot count backwards.
  For example:  </p>
  
  <pre><code>my $foo = ($bar[0..-2]);  
  </code></pre>
  
  <p>or  </p>
  
  <pre><code>my $foo = ($bar[-2..0]);  
  </code></pre>
  
  <p>Any help would be greatly appreciated as this is starting to drive me insane, and I have been unable to find a solution elsewhere or by experimenting.<br>
  Oskar</p>