I tried implementing this out of curiousity. HE* DO have a pointer back to the original hash, but there's no guaranteeing that the hash is there any more.

Thats why I tried using weakened references in stead. I would have used set/get magic if I was more comfortable with them, I never got those to work out for me before. Here's the begginings of the module (untested):
package Tie::BUKHash; sub TIEHASH { bless {}, ref $_[0] or $_[0]; } sub FETCH { my ($this, $key) = @_; return new Tie::BUKHash::Elem( $this, $key ); } sub STORE { my ($this, $key, $value) = @_; $this->{$key} = $value; } package Tie::BUKHash::Elem; use WeakRef 'weaken'; use Carp 'croak'; use constant HASH => 0; use constant KEY => 1; sub new { my ($proto, $hash, $key) = @_; my $self = bless [weaken($hash), $key], ref $proto or $proto; } sub get { my $self = shift; my $hash = $self->gethash; return $hash->{$self->[KEY]}; } sub set { my ($self, $val) = @_; my $hash = $self->gethash; $hash->{$self->[KEY]} = $val; } sub delete { my $self = shift; my $hash = $self->gethash; delete $hash->{$self->[KEY]}; } sub gethash { my $self = shift; return $self->[HASH] or croak "You shouldn't keep hash entries around after their respe +ctive hashes are gone!" ; }

In reply to Re^4: Pronoun Programming by plobsing
in thread Pronoun Programming by rje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.