use Devel::Size qw/total_size/; $h{$_} = 1 for "aaaaa".."zzzzz"; $elements_size += total_size $_ for %h; $hash_size = total_size \%h; print <