Help for this page

Select Code to Download


  1. or download this
    my %hash = ();
    $hash{'foo'} = undef;
    ...
    } else {
      print "The key 'foo' is false.\n";
    }
    
  2. or download this
    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";
    
  3. or download this
    my $entry = { firstname => 'Ola', lastname => 'Nordmann' }; 
    my $staff = {};
    ...
      $staff->{$id}->{'lastname'}, 
      $staff->{$id}->{'firstname'}
    );