#!/usr/bin/perl use strict; use warnings; use Benchmark 'cmpthese'; my %hash=qw(Das 1 ist 2 ein 3 test 4); cmpthese(300_000, { 'for' => sub { my $size=0; $size+=length($_) for(%hash); }, 'map' => sub { my $size=0; map{$size+=length($_)}%hash; }, 'join' => sub { my $size=length(join('',%hash)); }, });