Mur has asked for the wisdom of the Perl Monks concerning the following question:
My approach was to write your basic Tie::Hash class, and to override EXISTS, STORE, etc. One thing I tried to do but which doesn't appear to work is to change the way exists() works: it should return '0' if no match is found, or the list of hash keys that match (or the first match, if not in list context).my %hash; tie %hash, 'Nexcerpt::Keyword'; $hash{dog} = 1; print $hash{dogs}; # should print '1' print $hash{dogged}; # ditto
However, what appears to be happening is that my nice list of values returned at the end of my EXISTS routine, is being silently converted somewhere internally to a true/false. Is there a way around this? (I could always just write another method called "matches", but I'm stubborn.)
| -- | |||||||
|
| ||||||
| ...Nexcerpt...Connecting People With Expertise | |||||||
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Override exists()?
by Joost (Canon) on Dec 13, 2002 at 14:50 UTC | |
by Mur (Pilgrim) on Dec 13, 2002 at 15:21 UTC | |
|
(tye)Re: Override exists()?
by tye (Sage) on Dec 13, 2002 at 18:14 UTC |