package Redirect_Hash; sub TIEHASH { my ($class, $prefix) = @_; $prefix = 'redirect_' unless defined $prefix; my $self = [$prefix, {}]; bless $self => $class; } sub STORE { my ($self, $key, $value) = @_; my ($prefix, $hash) = @$self; if (index($key, $prefix) == 0) { my $truncated = substr($key, length($prefix)); $hash->{$truncated} = $value unless exists $hash->{$truncated}; } $hash->{$key} = $value; } sub FETCH { my ($self, $key) = @_; my ($prefix, $hash) = @$self; $hash->{$key}; }