use strict; my $bar = 'bar'; my $foo{$bar} = 1; my $foo{$bear} = 1; # gives a compile error