in reply to Making a failed hash lookup return something other than undef
You could use a tied hash where FETCH checks that the key exists before returning it. If it doesn't exist, it returns a default value (perhaps supplied when you called tie. All the other tied hash methods access the internal hash directly.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
|
|---|