Tuesday 31 January 2023

Perl Datastructures - Hash of Hash

Perl hash of hashes is a data structure that consists of a hash that contains other hashes as values. Each hash contained in the main hash can be accessed using a unique key.

Here's an example of how to create a hash of hashes in Perl:

my %HoH = (
   'John' => {
      'age' => 35,
      'occupation' => 'Programmer',
      'salary' => 50000,
   },
   'Mary' => {
      'age' => 27,
      'occupation' => 'Designer',
      'salary' => 40000,
   },
   'Mark' => {
      'age' => 42,
      'occupation' => 'Manager',
      'salary' => 70000,
   },
);
Read more »

Labels: