I'm a fan of Hash::Util when working with hash-based objects, myself. I tend to use init routines that look like this (to make it impossible to accidentally create a hashkey that's not supposed to be there):
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; }

In reply to Re^2: Death to auto-vivification by doom
in thread Death to auto-vivification by DrHyde

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":