@a=1.10; @b=1..100; @c=1..1000; @d=1..10000; use Benchmark 'cmpthese'; $ari = '@A = keys %{{ map +($_ => undef), @a, @b, @c, @d }};'; $buk = '@B = do{local %h; ++@h{@a,@b,@c,@d}; keys %h};'; cmpthese( -1, { ari=>$ari, buk=>$buk }); (warning: too few iterations for a reliable count) (warning: too few iterations for a reliable count) Rate ari buk ari 1.69/s -- -28% buk 2.36/s 39% -- cmpthese( -3, { ari=>$ari, buk=>$buk }); Rate ari buk ari 1.81/s -- -22% buk 2.32/s 28% -- cmpthese( -3, { ari=>$ari, buk=>$buk }); Rate ari buk ari 1.82/s -- -24% buk 2.40/s 32% -- print 'Same' if "@A" eq "@B" Same