sub sort_unique_hash { my %hash; @hash{@_} = (); return sort keys %hash; } #### Benchmark: timing 100000 iterations of foreach, hash... foreach: 14 secs (13.50 usr 0.00 sys = 13.50 cpu) hash: 6 secs ( 5.85 usr 0.00 sys = 5.85 cpu) #### @list = qw/foo bar baz foo quack bar baz/; #### @list = ('foo') x 1000; #### Benchmark: timing 1000 iterations of foreach, hash... foreach: 12 secs (11.82 usr 0.00 sys = 11.82 cpu) hash: 1 secs ( 0.88 usr 0.00 sys = 0.88 cpu)