use Hash::Util qw( lock_keys ); my %doc = ( filename => '', fileID => undef, tags => [] ); lock_keys(%doc); #### %> reply 0> use MooX::Struct -rw, Document => [ qw( $fileID $filename @tags ) ]; 1> my $doc = Document[ 1, "PetsFile"]; $res[0] = bless( { 'fileID' => 1, 'filename' => 'PetsFile' }, 'MooX::Struct::__ANON__::0001' ) 2> $doc->{foo} = 'bar'; $res[1] = 'bar' 3> delete $doc->{fileID}; $res[2] = 1 4> $doc $res[3] = bless( { 'filename' => 'PetsFile', 'foo' => 'bar' }, 'MooX::Struct::__ANON__::0001' ) 5>