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


in reply to move all 0s in an array to the beginning keeping other elements order same

Probably a duplicate, but my contribution:
$ perl -le '@x = (1, 2, 3, 4, 2, 1, 2, 0, 1, 0, 0); for ( @x ) { ( $_ ) ? push @y, $_ : unshift @y, $_; } print "@y\n"; ' __output__ 0 0 0 1 2 3 4 2 1 2 1