Hash::Util's lock_keys

Yitzchak Scott-Thoennes sthoenna at gmail.com
Wed Feb 19 17:20:56 GMT 2014


On Wed, Feb 19, 2014 at 6:04 AM, David Cantrell <david at cantrell.org.uk> wrote:
> On Wed, Feb 19, 2014 at 02:51:09PM +0100, Abigail wrote:
>> Even without strict, typos in variables at least warn (assuming warnings
>> are on), while typos in string literals at best give you a run time
>> error or warning.
>
> This is why I like using Tie::Hash::Vivify:
>
> my $hash = Tie::Hash::Vivify->new(sub {
>     confess("No auto-vivifying\n".Dumper(\@_));
> });
>
> It's still a run-time error, but at least it's a nice obvious run-time
> error.  But I confess to not basing my objects on it. I suppose I could,
> because re-blessing tied objects does leave the tie() magic intact.

Wouldn't work so well for named parameters, which are likely to be optional.

The name of that module is unfortunate; we already have enough trouble
with people not understanding that autovivification happens when you
do writish kinds of things to a nonexistent hash element, not when you
simply read it.


More information about the london.pm mailing list