#! perl -slw use strict; use Hash::Util qw[ lock_hash ]; my %set = map{ $_ => 1 } qw[ age old years ]; lock_hash %set; for my $unknown ( qw[ age sex old young years minutes] ) { print "$unknown ", exists $set{ $unknown } ? 'exists' : ' does not exist'; } $set{ fred } = 1; __END__ c:\test>junk3 age exists sex does not exist old exists young does not exist years exists minutes does not exist Attempt to access disallowed key 'fred' in a restricted hash at c:\test\junk3.pl line 15.