in reply to hash, a troublemaker?

You might find fields useful, although you'd have to create an object instead of a plain hash, and you'd need a different class for each hash.

{ package FooBar; use fields qw( foo bar ); sub new { fields::new(shift) } } my $ref = new FooBar; $ref->{foo} = 1; # Okay $ref->{quv} = 2; # Kablooie!

I'd guess that with Symbol one could create a class factory that would return a singleton object with the fields you request.