in reply to Re: Death to auto-vivification
in thread Death to auto-vivification
use Hash::Util qw( lock_keys unlock_keys ); sub init { my $self = shift; my $args = shift; unlock_keys( %{ $self } ); my @attributes = qw( something_or_other another_something ); foreach my $field (@attributes) { $ATTRIBUTES{ $field } = 1; $self->{ $field } = $args->{ $field }; } lock_keys( %{ $self } ); return $self; }
|
|---|