Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

I have the numbers 1 to n UPDATE: n is always a multiple of four.

I want to arrange them in the order "highest, lowest, next-lowest, next-highest, next-highest, next-lowest, etc".

For instance, with the numbers one to eight I want "8,1,2,7,6,3,4,5".

This code gets the job done, but I feel it's clunky. Anyone got a smarter way?

my @array = ( 1 .. 8 ); my @other_array = (); while (@array) { if ( $array[0] % 2 ) { push( @other_array, pop(@array), shift(@array) ); } else { push( @other_array, shift(@array), pop(@array) ); } } print "@other_array";

Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...