{"id":7951,"date":"2004-09-24T15:33:37","date_gmt":"2004-09-24T13:33:37","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/2004\/09\/24\/working-with-hashes-in-perl\/"},"modified":"2015-02-10T22:17:52","modified_gmt":"2015-02-10T20:17:52","slug":"working-with-hashes-in-perl","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2004\/09\/24\/working-with-hashes-in-perl\/","title":{"rendered":"Working with hashes in Perl"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><img decoding=\"async\" class=\"alignright\" src=\"\/wordpress\/wp-content\/20040923-perl_logo.jpeg\" alt=\"\" \/>There are several very useful modules at <a href=\"http:\/\/www.cpan.org\">CPAN<\/a> to work with Perl hashes. Here is a short list to get you started.<\/p>\n<ul>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-Hash-Approx\/lib\/Tie\/Hash\/Approx.pm\">Tie::Hash::Approx<\/a> &#8211; use key approximation to find values.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-AliasHash\/AliasHash.pm\">Tie::AliasHash<\/a> &#8211; use multiple keys for a single value.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-Hash-Expire\/Expire.pm\">Tie::Hash::Expire<\/a> &#8211; expire keys in hash after a predefined period of time.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Bloom-Filter\/Filter.pm\">Bloom::Filter<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Bloom16\/Bloom16.pm\">Bloom16<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Text-Document\/Bloom.pod\">Text::Bloom<\/a> &#8211; implementation of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bloom_filter\">Bloom&#8217;s filter algorithm<\/a>.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-Hash-Regex\/Regex.pm\">Tie::Hash::Regex<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Tie-RegexpHash\/RegexpHash.pm\">Tie::RegexpHash<\/a> &#8211; use regular expressions to match hash keys.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-SortHash\/SortHash.pm\">Tie::SortHash<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Tie-Hash-Rank\/lib\/Tie\/Hash\/Rank.pm\">Tie::Hash::Rank<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Tie-InsertOrderHash\/InsertOrderHash.pm\">Tie::InsertOrderHash<\/a>, <a href=\"http:\/\/search.cpan.org\/dist\/Tie-Hash-Indexed\/lib\/Tie\/Hash\/Indexed.pm\">Tie::Hash::Indexed<\/a>, <a href=\"http:\/\/search.cpan.org\/~gsar\/Tie-IxHash-1.21\/lib\/Tie\/IxHash.pm\">Tie::IxHash<\/a> &#8211; sorting hashes by key, by value; keeping hashes sorted, keeping elements in the same order they were inserted, etc.<\/li>\n<li><a href=\"http:\/\/search.cpan.org\/dist\/Tie-RangeHash\/lib\/Tie\/RangeHash.pm\">Tie::RangeHash<\/a> &#8211; associating values with a range of keys (e.g.: from 1 to 6 is &#8220;a&#8221;, from 7 to 10 is &#8220;b&#8221;, etc)<\/li>\n<\/ul>\n<p>I&#8217;ve used <a href=\"http:\/\/www.opennet.ru\/opennews\/art.shtml?num=4402\">this article<\/a> (in Russian) as a base for this post.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>There are several very useful modules at CPAN to work with Perl hashes. Here is a short list to get you started. Tie::Hash::Approx &#8211; use key approximation to find values. Tie::AliasHash &#8211; use multiple keys for a single value. Tie::Hash::Expire &#8211; expire keys in hash after a predefined period of time. Bloom::Filter, Bloom16, Text::Bloom &#8211; &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2004\/09\/24\/working-with-hashes-in-perl\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Working with hashes in Perl<\/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":[850,36],"keyring_services":[],"class_list":["post-7951","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-algorithms","tag-perl"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":173,"url":"https:\/\/mamchenkov.net\/wordpress\/2003\/03\/27\/programming\/","url_meta":{"origin":7951,"position":0},"title":"Programming","author":"Leonid Mamchenkov","date":"March 27, 2003","format":false,"excerpt":"Today was a very productive day. First half of the day I was doing PHP programming like mad. Second half of the day - perl. Perl feels like a releif after PHP. Hashes, regexps with =~, proper foreach loops...Yummy! Moved some of the production staff off from my workstation onto\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":8006,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/10\/05\/sending-a-hash-to-perls-scalar-function\/","url_meta":{"origin":7951,"position":1},"title":"Sending a hash to perl&#8217;s scalar function","author":"Leonid Mamchenkov","date":"October 5, 2004","format":false,"excerpt":"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\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":11200,"url":"https:\/\/mamchenkov.net\/wordpress\/2008\/05\/19\/php-6-hopefully-not-the-end-of-the-road\/","url_meta":{"origin":7951,"position":2},"title":"PHP 6 &#8211; hopefully not the end of the road","author":"Leonid Mamchenkov","date":"May 19, 2008","format":false,"excerpt":"I've heard plenty of positive buzz about PHP 6 in the last few weeks.\u00a0 Yes, it's coming out.\u00a0 Yes, it brings quite a few improvements, including better Unicode support, better security, and more help for larger projects through namespaces.\u00a0 However, I hope that it won't be the last PHP release,\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":211,"url":"https:\/\/mamchenkov.net\/wordpress\/2003\/05\/05\/perl-bits\/","url_meta":{"origin":7951,"position":3},"title":"Perl bits","author":"Leonid Mamchenkov","date":"May 5, 2003","format":false,"excerpt":"Here is a nice article covering date\/time functionality in perl and CPAN modules. And here is also a link to Tie::Cycle module, which will help all those doing striped tables in HTML and any other \"flagged\" tricks. And to complete the whole perl thing, here is a nice article at\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":9451,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/09\/14\/working-with-named-pipes-in-perl\/","url_meta":{"origin":7951,"position":4},"title":"Working with named pipes in Perl","author":"Leonid Mamchenkov","date":"September 14, 2005","format":false,"excerpt":"The collegue of mine came across a problem that developed into an interesting solution that I decided to share with the world. Actually, I think the world is pretty much aware of the solution, but just in case that I will ever be looking for this solution again, I'll have\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":9592,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/10\/20\/synchronizing-directories-with-perl-and-ssh\/","url_meta":{"origin":7951,"position":5},"title":"Synchronizing directories with Perl and SSH","author":"Leonid Mamchenkov","date":"October 20, 2005","format":false,"excerpt":"For a while now I have been using ICQ both at home and at work. Instead of having two different copies of data or running ICQ remotely, I was simply copying all data files over between these two locations. rsync with scp were doing the job just fine. The problem\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\/7951","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=7951"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/7951\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=7951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=7951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=7951"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=7951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}