Probably the simplest thing would be to subclass BerkeleyDB::Hash and override the FETCH() and STORE() methods something like (untested):
package BerkeleyDB::Hash::CasePreserve; sub FETCH { my( $self, $key ) = @_; unless( $self->EXISTS( $key ) ) { my $key_re = qr/\A$key\z/i; my $check = $self->FIRSTKEY( ); do { if( $check =~ $key_re ) { $key = $check; last; } } while( $check = $self->NEXTKEY( $check ) ); } return $self->SUPER::FETCH( $key ); }
Update: Added anchored $key_re.
In reply to Re: Tie one hash two ways?
by Fletch
in thread Tie one hash two ways?
by MrMadScience
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |