Category: | Tied Variables |
Author/Contact Info | davorg <dave@dave.org.uk> |
Description: | A tied hash that does regex matching on keys if an exact match isn't found. You'd use it like this:
The last is, of course, of limited use as it just matches the first key it finds in the hash. |
package Tie::Hash::Regex; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; require Tie::Hash; @ISA = qw(Exporter Tie::StdHash); @EXPORT = qw(); @EXPORT_OK =(); $VERSION = '0.01'; sub FETCH { my $self = shift; my $key = shift; return $self->{$key} if exists $self->{$key}; foreach (keys %$self) { return $self->{$_} if /$key/; } return; } 1; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Tie::Hash::Regex
by japhy (Canon) on May 11, 2001 at 18:07 UTC | |
by davorg (Chancellor) on May 11, 2001 at 19:50 UTC | |
by davorg (Chancellor) on May 24, 2001 at 22:22 UTC | |
Re: Tie::Hash::Regex
by Masem (Monsignor) on May 11, 2001 at 17:22 UTC | |
by davorg (Chancellor) on May 11, 2001 at 17:28 UTC | |
by Masem (Monsignor) on May 11, 2001 at 18:14 UTC |
Back to
Code Catacombs