Hash Buckets trivia
Jeff Klein
jklein at triton.net
Tue Apr 2 13:40:48 CST 2002
A follow-up to the trivia question at the last meeting -- a hash in a scalar
context returns the number of hash buckets used and the number allocated.
===
for $i (1..1000) {
$h{$i} = 1;
}
print scalar(%h), "\n";
print scalar(keys %h), "\n";
===
541/1024
1000
===
Note that neither of these is the number of entries in the hash, exactly why
is a matter of Perl's internal implementation.
-Jeff
More information about the grand-rapids-pm-list
mailing list