1 #--------------------------#
2 package PLP::Tie::Delay;
3 #--------------------------#
9 Delays hash generation. Unties the hash on first access, and replaces it by the generated one.
10 Uses symbolic references, because circular ties make Perl go nuts :)
12 tie %Some::hash, 'PLP::Tie::Delay', 'Some::hash', sub { \%generated_hash };
14 This module is part of the PLP internals and probably not of any use to others.
21 %{$self->[0]} = %{ $self->[1]->() };
25 my ($class, $hash, $source) = @_;
26 return bless [$hash, $source], $class;
30 my ($self, $key) = @_;
32 return ${$self->[0]}{$key};
36 my ($self, $key, $value) = @_;
38 return ${$self->[0]}{$key} = $value;
42 my ($self, $key) = @_;
44 return delete ${$self->[0]}{key};
54 my ($self, $key) = @_;
56 return exists ${$self->[0]}{key};
62 return exists ${$self->[0]}{key};