|
NAMETie::RegexpHash - Use regular expressions as hash keysSYNOPSISuse Tie::RegexpHash; my %hash; tie %hash, 'Tie::RegexpHash'; $hash{ qr/^5(\s+|-)?gal(\.|lons?)?/i } = '5-GAL'; $hash{'5 gal'}; # returns "5-GAL" $hash{'5GAL'}; # returns "5-GAL" $hash{'5 gallon'}; # also returns "5-GAL" my $rehash = Tie::RegexpHash->new(); $rehash->add( qr/\d+(\.\d+)?/, "contains a number" ); $rehash->add( qr/s$/, "ends with an \`s\'" ); $rehash->match( "foo 123" ); # returns "contains a number" $rehash->match( "examples" ); # returns "ends with an `s'" DESCRIPTIONThis module allows one to use regular expressions for hash keys, so that values can be associated with anything that matches the key.Hashes can be operated on using the standard tied hash interface in Perl, as described in the SYNOPSIS, or using an object-oriented interface described below. Methods
AUTHORRobert Rothenberg <rrwo at cpan.org>, previous maintainer.MAINTAINERAlastair McGowan-Douglas <altreus@cpan.org>AcknowledgmentsRussell Harrison <rch at cpan.org> for patches adding support for serialization.Simon Hanmer <sch at scubaplus.co.uk> & Bart Vetters <robartes at nirya.eb> for pointing out a bug in the logic of the _find() routine in v0.10 BUGSPlease report bugs on the github issues tracker <https://github.com/Altreus/Tie-RegexpHash/issues>. Request Tracker tickets will probably go unseen.LICENSECopyright (c) 2001-2002, 2005-2006 Robert Rothenberg. All rights reserved.Portions Copyright (c) 2014-2015 Alastair McGowan-Douglas. Portions Copyright (c) 2006 Russell Harrison. All rights reserved. This program is free software. You can redistribute it under the terms of the Artistic Licence <http://dev.perl.org/licenses/artistic.html>. SEE ALSOTie::Hash::Regex is a module with a complementary function. Rather than a hash with Regexps as keys that match against fetches, it has standard keys that are matched by Regexps in fetches.Regexp::Match::Any matches many Regexps against a variable. Regexp::Match::List is similar, but supports callbacks and various optimizations.
Visit the GSP FreeBSD Man Page Interface. |