My method  sounds stupid, but still works :

my @array = ('123', 'abc', 'def',  1..9);
my $len_of_array =  0 ;
foreach my $elem(@array)
{    $len_of_array += length($elem) }
print $len_of_array ; # I got '18'

my %hash = (1=>2, 2=>3, 3=>4);
foreach my $key(keys(%hash))
{    $len_of_hash += length($key) + length($hash{$key}) }
print $len_of_hash ; # I got '6'

I suppose there should be another better and faster way to done this, 
any suggestion ?

Reply via email to