my @a = (0..1000, 0..1000); Benchmark::timethese($ARGV[0]||-1,{  "shift" => sub {     my (%seen, $string);     my @array = @a;     $seen{$string}++ while defined ($string = shift @array);     for (keys %seen) {        push @array, $_; delete $seen{$_};     } return @array;  },  "grep"  => sub {     my %seen;     my @unique = grep { ! $seen{$_}++ } @a;  }, }); __END__      grep:  1 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 614.42/s (n=639)     shift:  1 wallclock secs ( 1.03 usr +  0.00 sys =  1.03 CPU) @ 296.12/s (n=305)