http://qs321.pair.com?node_id=11116864


in reply to Converting Hashes to Objects

If you're not tied to creating objects, I found locking hashes quite good to prevent typos:

use Hash::Util 'lock_keys'; my $hash = h2o { foo => "bar", x => "y" }, qw/ more keys /; lock_keys $hash; print $hash->{ foo }, "\n"; # prints "bar" $hash->{ x } = "z"; # setter $hash->{batman} = 'secret'; # dies