http://www.perlmonks.org?node_id=615494


in reply to Seeking explanation on assigning a hash to a scalar

imp and Samy_rio have shown you the documentation that demonstrates that there is a meaning to the result you got. Perhaps you were expecting the assignment of a hash to a scalar to behave in a similar way to assigning an array to a scalar, i.e. give the number of keys and values in the hash. If that was what you wanted you can do that like this

use strict; use warnings; my %hash = (a => 1, b => 2, c => 3); my $buckets = %hash; my $elems = () = %hash; print qq{ Buckets: $buckets\nElements: $elems\n};

which prints

Buckets: 3/8 Elements: 6

I hope this is of interest.

Cheers,

JohnGG