sub FETCH { my ($this, $key)=@_;
return $this->{'l'}{$key} if exists $this->{'l'}{$key};
print "trying f's $key: $this->{f}{$key}\n";
$this->{'l'}{$key}=eval($this->{f}{$key});
return $this->{'l'}{$key};
}
Can't use an undefined value as a HASH reference at t2.pl line 27.
Why does pwotie's FETCH work ok with $o{0} called first, but fail when $o{0}->{hi} is called first?
####
sub FETCH {
my ($this, $key) = @_;
return $this->{l}{$key} if exists $this->{l}{$key};
# I don't know what you're doing, but eval is scary :)
# Consider using a sub ref (sub { ... } or \&subname) instead
$this->{l}{$key} = eval $this{f}{$key};
# Create a new hash ref if the eval returned undef
$this->{l}{$key} = { } if not defined $this->{l}{$key};
return $this->{l}{$key};
}