in reply to Re: Array rearrangement hangup.
in thread Array rearrangement hangup.

...Looking at it, that makes sense. It just reads a new value for i, doesn't it? Thanks.

Replies are listed 'Best First'.
Re^3: Array rearrangement hangup.
by ikegami (Patriarch) on Mar 15, 2006 at 23:17 UTC
    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. :-/