{"id":16315200,"url":"https://github.com/robrwo/hash-match","last_synced_at":"2026-02-16T19:05:52.013Z","repository":{"id":18135326,"uuid":"21216414","full_name":"robrwo/Hash-Match","owner":"robrwo","description":"Create matching rules against the contents of a hash","archived":false,"fork":false,"pushed_at":"2025-01-02T21:32:23.000Z","size":140,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T22:59:03.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrwo.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-25T19:50:36.000Z","updated_at":"2025-01-02T21:32:27.000Z","dependencies_parsed_at":"2024-11-06T09:23:44.469Z","dependency_job_id":"aadee5d9-2a40-4489-adb9-898f3fe52157","html_url":"https://github.com/robrwo/Hash-Match","commit_stats":{"total_commits":83,"total_committers":3,"mean_commits":"27.666666666666668","dds":"0.15662650602409633","last_synced_commit":"183188a748a90ee85ad83b151026ec4bf421df26"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FHash-Match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FHash-Match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FHash-Match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FHash-Match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrwo","download_url":"https://codeload.github.com/robrwo/Hash-Match/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167440,"owners_count":21223505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T21:56:29.810Z","updated_at":"2026-02-16T19:05:51.942Z","avatar_url":"https://github.com/robrwo.png","language":"Perl","readme":"# NAME\n\nHash::Match - match contents of a hash against rules\n\n# VERSION\n\nversion v0.8.3\n\n# SYNOPSIS\n\n```perl\nuse Hash::Match;\n\nmy $m = Hash::Match-\u003enew( rules =\u003e { key =\u003e qr/ba/ } );\n\n$m-\u003e( { key =\u003e 'foo' } ); # returns false\n$m-\u003e( { key =\u003e 'bar' } ); # returns true\n$m-\u003e( { foo =\u003e 'bar' } ); # returns false\n\nmy $n = Hash::Match-\u003enew( rules =\u003e {\n   -any =\u003e [ key =\u003e qr/ba/,\n             key =\u003e qr/fo/,\n           ],\n} )\n\n$n-\u003e( { key =\u003e 'foo' } ); # returns true\n```\n\n# DESCRIPTION\n\nThis module allows you to specify complex matching rules for the\ncontents of a hash.\n\n# METHODS\n\n## `new`\n\n```perl\nmy $m = Hash::Match-\u003enew( rules =\u003e $rules );\n```\n\nReturns a function that matches a hash reference against the\n`$rules`, e.g.\n\n```\nif ( $m-\u003e( \\%hash ) ) { ... }\n```\n\n### Rules\n\nThe rules can be a hash or array reference of key-value pairs, e.g.\n\n```perl\n{\n  k_1 =\u003e 'string',    # k_1 eq 'string'\n  k_2 =\u003e qr/xyz/,     # k_2 =~ qr/xyz/\n  k_3 =\u003e sub { ... }, # k_3 exists and sub-\u003e($hash-\u003e{k_3}) is true\n}\n```\n\nFor a hash reference, all keys in the rule must exist in the hash and\nmatch the criteria specified by the rules' values.\n\nFor an array reference, some (any) key must exist and match the\ncriteria specified in the rules.\n\nYou can specify more complex rules using special key names:\n\n- `-all`\n\n    ```perl\n    {\n      -all =\u003e $rules,\n    }\n    ```\n\n    All of the `$rules` must match, where `$rules` is an array or hash\n    reference.\n\n- `-any`\n\n    ```perl\n    {\n      -any =\u003e $rules,\n    }\n    ```\n\n    Any of the `$rules` must match.\n\n- `-notall`\n\n    ```perl\n    {\n      -notall =\u003e $rules,\n    }\n    ```\n\n    Not all of the `$rules` can match (i.e., at least one rule must\n    fail).\n\n- `-notany`\n\n    ```perl\n    {\n      -notany =\u003e $rules,\n    }\n    ```\n\n    None of the `$rules` can match.\n\n- `-and`\n\n    This is a (deprecated) synonym for `-all`.\n\n- `-or`\n\n    This is a (deprecated) synonym for `-any`.\n\n- `-not`\n\n    This is a (deprecated) synonym for `-notall` and `-notany`,\n    depending on the context.\n\nNote that rules can be specified arbitrarily deep, e.g.\n\n```perl\n{\n  -any =\u003e [\n     -all =\u003e { ... },\n     -all =\u003e { ... },\n  ],\n}\n```\n\nor\n\n```perl\n{\n  -all =\u003e [\n     -any =\u003e [ ... ],\n     -any =\u003e [ ... ],\n  ],\n}\n```\n\nThe values for special keys can be either a hash or array\nreference. But note that hash references only allow strings as keys,\nand that keys must be unique.\n\nYou can use regular expressions for matching keys. For example,\n\n```perl\n-any =\u003e [\n  qr/xyz/ =\u003e $rule,\n]\n```\n\nwill match if there is any key that matches the regular expression has\na corresponding value which matches the `$rule`.\n\nYou can also use\n\n```perl\n-all =\u003e [\n  qr/xyz/ =\u003e $rule,\n]\n```\n\nto match if all keys that match the regular expression have\ncorresponding values which match the `$rule`.\n\nYou can also use functions to match keys. For example,\n\n```perl\n-any =\u003e [\n  sub { $_[0] \u003e 10 } =\u003e $rule,\n]\n```\n\n# SUPPORT FOR OLDER PERL VERSIONS\n\nSince v0.8.0, the this module requires Perl v5.14 or later.\n\nFuture releases may only support Perl versions released in the last ten (10) years.\n\n# SEE ALSO\n\nThe following modules have similar functionality:\n\n- [Data::Match](https://metacpan.org/pod/Data%3A%3AMatch)\n- [Data::Search](https://metacpan.org/pod/Data%3A%3ASearch)\n\n# SOURCE\n\nThe development version is on github at [https://github.com/robrwo/Hash-Match](https://github.com/robrwo/Hash-Match)\nand may be cloned from [git://github.com/robrwo/Hash-Match.git](git://github.com/robrwo/Hash-Match.git)\n\n# BUGS\n\nPlease report any bugs or feature requests on the bugtracker website\n[https://github.com/robrwo/Hash-Match/issues](https://github.com/robrwo/Hash-Match/issues)\n\nWhen submitting a bug or request, please include a test-file or a\npatch to an existing test-file that illustrates the bug or desired\nfeature.\n\n## Reporting Security Vulnerabilities\n\nSecurity issues should not be reported on the bugtracker website.  Please see `SECURITY.md` for instructions how to\nreport security vulnerabilities\n\n# AUTHOR\n\nRobert Rothenberg \u003crrwo@cpan.org\u003e\n\nSome development of this module was based on work for\nFoxtons [http://www.foxtons.co.uk](http://www.foxtons.co.uk).\n\n# CONTRIBUTOR\n\nMohammad S Anwar \u003cmohammad.anwar@yahoo.com\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2014-2015, 2018-2025 by Robert Rothenberg.\n\nThis is free software, licensed under:\n\n```\nThe Artistic License 2.0 (GPL Compatible)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fhash-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrwo%2Fhash-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fhash-match/lists"}