#! perl -slw use strict; use Benchmark::Timer; our $N ||= 1e6; my $T = new Benchmark::Timer; my @array; push @array, sprintf "Test%07d", int rand 32767 for 1 .. $N; $T->start( 'sort -u' ); open my $pipe, "| u:sort -u > temp.tmp" or die $!; print $pipe $_ for @array; close $pipe; open my $in, '<', 'temp.tmp' or die $!; my $i = 0; $array[ $i++ ] = $_ while <$in>; close $in; $#array = $i - 1; ## Corrected, with thanks to [johngg] $T->stop( 'sort -u' ); $T->report; printf "Array now contains %d uniq elements\n", scalar @array; __END__ [ 8:17:47.37] c:\test>551753-2 -N=1e7 1 trial of sort -u (183.281s total) Array now contains 32768 uniq elements