{"id":8006,"date":"2004-10-05T15:36:04","date_gmt":"2004-10-05T13:36:04","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/2004\/10\/05\/sending-a-hash-to-perls-scalar-function\/"},"modified":"2005-04-17T07:38:35","modified_gmt":"2005-04-17T04:38:35","slug":"sending-a-hash-to-perls-scalar-function","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2004\/10\/05\/sending-a-hash-to-perls-scalar-function\/","title":{"rendered":"Sending a hash to perl&#8217;s scalar function"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><img decoding=\"async\" class=\"alignright\" src=\"\/wordpress\/wp-content\/20040923-perl_logo.jpeg\" alt=\"\"\/>While writing a test suite for one of my applications today, I came across an interesting result.  Perl&#8217;s scalar function, if given a hash as an argument, will return something like &#8220;2\/8&#8221; or &#8220;5\/16&#8221;.  Results can be identical for different hashes.  There is no obvioius trend in changing of these results.  As it turned out, <code>scalar(%hash)<\/code> 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.<\/p>\n<p>I wasn&#8217;t sure in my guess, until I got a confirmation from <a href=\"http:\/\/www.perlmonks.com\/?node_id=396518\">Perl monks<\/a>, which also pointed me to the &#8220;man perldata&#8221; bit describing the result.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>While writing a test suite for one of my applications today, I came across an interesting result. Perl&#8217;s scalar function, if given a hash as an argument, will return something like &#8220;2\/8&#8221; or &#8220;5\/16&#8221;. Results can be identical for different hashes. There is no obvioius trend in changing of these results. As it turned out, &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2004\/10\/05\/sending-a-hash-to-perls-scalar-function\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Sending a hash to perl&#8217;s scalar function<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[36],"keyring_services":[],"class_list":["post-8006","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-perl"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":9196,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/07\/05\/profiling-perl\/","url_meta":{"origin":8006,"position":0},"title":"Profiling perl","author":"Leonid Mamchenkov","date":"July 5, 2005","format":false,"excerpt":"After I've complained on #perl channel that dprofpp (perl profiler) dies on me, I received a number of suggestions on how to profile the code without using dprofpp. Ideas ranged from elemetary insertion of 'print \"Started\", time,\"\\n\"' to all sorts of dynamic subroutine overloading. Here is one elegant solution that\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24399,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/06\/24\/rt-initialdata-and-perls-nested-map\/","url_meta":{"origin":8006,"position":1},"title":"RT initialdata and Perl&#8217;s nested map","author":"Leonid Mamchenkov","date":"June 24, 2015","format":false,"excerpt":"Request Tracker (aka RT) comes with a very powerful, yet not too widely known tool - initialdata. \u00a0This helps with automating\u00a0configuration of the new system and data migration. \u00a0Combined with the power of Perl's map() function, some really awesome things can be done in a jiffy. Here is a snippet\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9613,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/10\/26\/missing-some-regexp-knowledge\/","url_meta":{"origin":8006,"position":2},"title":"Missing some regexp knowledge","author":"Leonid Mamchenkov","date":"October 26, 2005","format":false,"excerpt":"Once in a while I come across some topic that I should have learned a billion years ago. Something very basic and useful that I had a chance of seeing many times but haven't, or probably had and ignored it. Today I found out that I was missing an important\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7402,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/03\/30\/php-zopepython-and-perl\/","url_meta":{"origin":8006,"position":3},"title":"PHP, Zope\/Python, and Perl","author":"Leonid Mamchenkov","date":"March 30, 2004","format":false,"excerpt":"There is an article at kuro5hin.net called \"Switching from PHP to Zope\/Python\". This should provide for an interesting read for all those poor PHP souls. As for me - I use Perl and I am not planning to change any time soon. There are two major bonuses in Perl for\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11298,"url":"https:\/\/mamchenkov.net\/wordpress\/2008\/06\/07\/programming-language-barrier\/","url_meta":{"origin":8006,"position":4},"title":"Programming language barrier","author":"Leonid Mamchenkov","date":"June 7, 2008","format":false,"excerpt":"One of the frequent things that I hear about programmers is that it doesn't matter which language the person is using and which language you need him to use, because if he is any good he'll learn and catch up pretty fast.\u00a0 In other words, if you take a decent\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9864,"url":"https:\/\/mamchenkov.net\/wordpress\/2006\/01\/26\/decimal-to-binary-convertion-in-perl\/","url_meta":{"origin":8006,"position":5},"title":"Decimal to binary convertion in Perl","author":"Leonid Mamchenkov","date":"January 26, 2006","format":false,"excerpt":"This is a simple thing, but when you need it - you need it. There is no need in implementing a function that does or looking for a module at CPAN. All you are looking for is already there. #!\/usr\/bin\/perl -w use strict; # Get the number from the command\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/8006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=8006"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/8006\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=8006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=8006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=8006"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=8006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}