perlquestion
McA
<p>Hi all,</p>
<p>once upon a time there was a hash introduced in our codebase. And the usage of that hash which was transferred to almost any function grew and grew. The usage of several keys cemented the "API" of that hash. After years I'm not happy with that because an object would have been the better approach (e.g. for the possibility to garantee the consistence of severals keys/value pairs). Now my question:</p>
<p>Is it possible to have somthing like Dr.-Jekyll-and-Mr. Hyde-object: A tied hash which is also blessed to be an object? Code would look like that:</p>
<code>
my $obj = DrJekyll->new;
$obj->{somekey} = 'something';
$obj->transform();
</code>
<p>Everyone knowing the standard way of representing objects as blessed hash refs will now say: Yes, of course. With a simple blessed hash you can do that. But I want to have control over the access to a key. That means as soon as someone codes <code>$obj->{somekey} = 'something';</code> I want a hook. That would be possible with tied hashes.</p>
<p>I hope this is an interesting question.</p>
<p>Best regards<br/>
McA</p>