http://qs1969.pair.com?node_id=1084692

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

I want to move all 0s in an array to the beginning keeping other elements order same.
@array = (1, 2, 3, 4, 2, 1, 2, 0, 1, 0, 0); @array1 = (); @array2 = (); foreach $i (@array) { push($i, @array1) if $i == 0; push($i, @array2) if $i != 0; } @new_array = (@array1, @array2);
Is there any better way to do this?