use warnings; use strict; no strict 'refs'; my %hash = ( badger => 'nadger', mutt => 'nut' ); # Package variable, named badger our $badger = 'furry'; # Lexical variable - gives a warning that it is shadowing # the package var my $badger = 'stripey'; my $str = 'badger'; # The value of $str is used to lookup in the hash # Hence this prints 'nadger' print $hash{$str}, "\n"; # With strict refs off, we can use '$str' as a reference and # so this prints 'furry', the value of the $badger package var print ${$str}, "\n"; # This is a normal variable lookup, whose value will be # 'stripey', since the lexical is shadowing the package var # in this scope. print $badger, "\n";