use strict; use warnings; use Set::Scalar; use Benchmark qw(cmpthese); my @array = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); cmpthese (-1, { 'GF' => sub {my %hash; @hash{@array} = (1) x @array;}, 'map' => sub {my %hash = map {($_, 1)} @array;}, 'map++' => sub {my %hash; map {$hash{$_}++} @array;}, 'set' => sub {my $set = Set::Scalar->new(@array);}, } );