Blog of Leonid Mamchenkov

You just stepped in a pile of posts.

Sending a hash to perl’s scalar function

Posted in All on October 5th, 2004 · No Comments

While writing a test suite for one of my applications today, I came across an interesting result. Perl’s scalar function, if given a hash as an argument, will return something like “2/8″ or “5/16″. Results can be identical for different hashes. There is no obvioius trend in changing of these results. As it turned out, scalar(%hash) returns information about hash buckets. The first number indicates the number of occupied buckets in the hash storage and the second number indicates the total number of buckets allocated.

I wasn’t sure in my guess, until I got a confirmation from Perl monks, which also pointed me to the “man perldata” bit describing the result.

Tags: , ,

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

Note: This post is over 4 years old. You may want to check later in this blog to see if there is new information relevant to your comment.