A less approximate version of Tie::Hash::Approx

David Cantrell david at cantrell.org.uk
Wed Mar 12 14:50:34 GMT 2008

I need a module that will let me tie a hash so that if I try to FETCH a
value for a key that exists, then it'll return the appropriate value,
but will also let me fetch values for keys that match certain rules.

eg so that ...

    tie %hash, ....
    $hash{Hobbes} = 'feline';
    $hash{Lassie} = 'canine';
    # set up some magic here

    print "Hobbes is a $hash{Hobbes}\n";
    print "Lassie is a $hash{Lassie}\n";
    print "42 is an $hash{42}\n";        # 42 gets caught by some magic
    print "3.5 is a $hash{3.5}\n";       # 3.5 matches some other magic
    print "Skippy is a $hash{Skippy}\n"; # Skippy doesn't exist

will print:

    Hobbes is a feline
    Lassie is a canine
    42 is an integer
    3.5 is a floating point number
    Skippy is a Use of uninitialized value in concatenation

without me having to define values for all real numbers, which would be
the sort of task I might set a work-experience kid if I don't like their

Can anyone point me at something on the CPAN, or am I going to have to
write this myself?

David Cantrell | top google result for "topless karaoke murders"

Feature: an incorrectly implemented bug

More information about the london.pm mailing list