{ my @new = (); my $in = sub { for(@array,@new){ return 1 if $_ eq $_[0] } return 0 }; local $_; while( @array ){ $_ = shift @array; #this is of course pseufo for really figuring out # a new value my $new = shift @figure_out or next; $in->($new) or push @array,$new; } continue { push @new,$_ } @array = @new; }