Dan Brian <[EMAIL PROTECTED]> wrote:
 >
 > Given a list of numbers, say, 1..12 for the months, and knowing the
 > month (i.e. 6), assign a list that is ((6..12),(1..5)).
 >
 > Assuming July, I have:
 >
 >   $m = 6;
 >   @ordered = ((1..12)[$m..11],(1..$m));
 >
 > What if the original list was 0..11?


Use wrap-around indexing (eg, july: [-6..5]):

$ perl -lwe'
 > @mon = qw(jan feb mar apr may jun jul aug sep oct nov dec);
 > $m = pop;
 > print "@mon[$m - 12 .. $m - 1]"' 6
jul aug sep oct nov dec jan feb mar apr may jun
$

  p

Reply via email to