in reply to Array rearrangement hangup.
Don't modify the loop variable in the loop. This is bad programming practice. If you want to do something like this, make the loop do it for you:for $i(0..$length2){ push @array2, $array[$i]; $i+=2; }
For the next section:for ($i=0;$i<=@array-2;$i+=2) { push @array2, $array[$i]; }
Careful you don't step off the array. While this works, it's fragile and easy to break.for $i(1..$length){ push @array2, $array[$i]; $i+=2; }
You should use strict; and use warnings;, and then use the debugger to find out where it goes horribly wrong ;)
I'd do it for you now, but I have to run for the carpool!
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|