my %hash = (); $hash{'foo'} = undef; if (exists $hash{'foo'}) { print "The key 'foo' exists.\n"; } else { print "The key 'foo' does not exist.\n"; } if (defined $hash{'foo'}) { print "The key 'foo' is defined.\n"; } else { print "The key 'foo' is undefined.\n"; } if ($hash{'foo'}) { print "The key 'foo' is true.\n"; } else { print "The key 'foo' is false.\n"; } #### my %inner_hash = ( dir => '/tmp/foo/', filename => 'bar.txt' ); my %hash_of_hashes = (); $hash_of_hashes{'baz'} = \%inner_hash; # Backslash = reference to print "The filename associated with 'baz' is " .$hash_of_hashes{'baz'}->{'filename'} . "\n"; #### my $entry = { firstname => 'Ola', lastname => 'Nordmann' }; my $staff = {}; my $id = 123; $staff->{$id} = $entry; printf( "%d: %s, %s\n", $id, $staff->{$id}->{'lastname'}, $staff->{$id}->{'firstname'} );