FreeKB - Multidimensional Hash
Perl - Multidimensional Hash

Let's say you want to create a hash that has two (or more) keys, like this. In this example, the "name" key is below the "employee" key.

'employee' {
             'name' => 'John Doe',
           }

 

Create the multidimensional keys and value.

my %hash = ( employee => { name => "John Doe" } );

 

Or like this.

my $hash{"employee"}->{"name"} = "John Doe";

 

Dumper can be used to print the hash.

print Dumper \%hash;

 

Which will produce the following.

$VAR1 = {
          'employee' => {
                          'name' => 'Jane Doe'
                        }
        };

 

Print the name key.

print $hash{"employee"}->{"name"};

 

Which will produce the following.

John Doe

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 83395 in the box below so that we can be sure you are a human.




Comments