title: How can I re-arrange array indexes in Perl?
body: <p>At first: Apologies for my not-so-good English, I'm a 17-year old German ;-)</p>
  
  <p>I do my apprentice as a web-developer and just stumbled upon a problem: </p>
  
  <p>I need to re-arrange the indexes of an array. The array is basically like that:</p>
  
  <pre><code>@array = ( 'a', 'b', 'c' );
  </code></pre>
  
  <p>But: it changes dynamically, so it doesnt always have 3 elements, but something over 20. Now, what I need to do is to get it to:</p>
  
  <pre><code>@array = ( 'c', 'a', 'b' ); 
  </code></pre>
  
  <p>So, I thought I just needed to do something like that (in a for-loop that loops once for every element in the array and increments $counter)</p>
  
  <pre><code>my $last = $array[$#array];
  for($#array)
  {
      $array[$counter] = $array[$counter + 1];
      unshift(@array, $last);
      pop(@array);
      $counter++;
  }
  </code></pre>
  
  <p>I thought it would do this:</p>
  
  <p>For each element in array (lets say, we are at element 0): Set element index = element index + 1; then add the last array to the beginning and remove the now "real" last array (which is just a duplicate of the beginning now). Then adding 1 to the counter and redo that for the array. But it doesnt really do what I want. </p>
  
  <p>Well, that was my "newbie" try, so again, thats what I just need:</p>
  
  <p>I need to "move" all the elements indexes of the array +1 and cut off the last one then to be at the beginning. The maybe more complicated thing is, that the arrays length is just variable. </p>
  
  <p>In another form: 
  I need to turn</p>
  
  <pre><code>( 'a', 'b', 'c', 'd', ... 'z');
  </code></pre>
  
  <p>to</p>
  
  <pre><code>( 'z', 'a', 'b', 'c', ... 'y' );
  </code></pre>
  
  <p>Ive got no idea how to go on and I would appreciate any help.</p>
  
  <p>Thanks :-)</p>
  
  <p><strong>Already thanks for all your anwers! I forgot to say that I cant test it before monday, because Im not at work anymore and I dont have the source with me right now. But thanks, Im sure at least one of your solutions will work!</strong></p>