in reply to Array rearrangement hangup.

The $i+=2 in your loop does nothing. The for will put the next value from the list into $i without checking its current value. You want
for ($i=0; $i<=$length2; $i+=2){ push @array2, $array[$i]; } for ($i=1; $i<=$length; $i+=2){ push @array2, $array[$i]; }
or
for $i(0..$length/2){ push @array2, $array[$i*2]; } for $i(0..$length/2){ push @array2, $array[$i*2+1]; }

Replies are listed 'Best First'.
Re^2: Array rearrangement hangup.
by Andrew_Levenson (Hermit) on Mar 15, 2006 at 23:15 UTC
    ...Looking at it, that makes sense. It just reads a new value for i, doesn't it? Thanks.
      You also have an off-by-one error. $length contains the number of elements in the array, which is one beyond the end of the array. The $i+=2 in your loop does nothing. The for will put the next value from the list into $i without checking its current value. You want
      for ($i=0; $i<$length2; $i+=2){ push @array2, $array[$i]; } for ($i=1; $i<$length; $i+=2){ push @array2, $array[$i]; }
      or
      for $i(0..($length-1)/2){ push @array2, $array[$i*2]; } for $i(0..($length-1)/2){ push @array2, $array[$i*2+1]; }
      or
      for $i(0..$#array/2){ push @array2, $array[$i*2]; } for $i(0..$#array/2){ push @array2, $array[$i*2+1]; }

      That doesn't fix your decrpytion (which is totally wrong), but it puts you at a point where you can start having a look at it.

        My decryption? I haven't posted that yet. ;)
        I'm actually going to have for your help on that one, too, because i'm totally stumped on the decryption program as well. :-/