The answer you entered to the math problem is incorrect.

Perl: HashMap

HashMap is the most powerful data structure available in any language. And is available in almost every language. Perl has one too and is called Hashes or Associative arrays.

To declare a hashmap, use a % sign as follows:

%testHashpMap = ();

Now, key/value pair can be added and accessed as follows:

$testHashpMap {$key} = $value;

Note, curly braces {} in the hashmap.

A small program that illustrates this:

%testHashpMap = ();

$testHashpMap {"delhi"} = "india";
$testHashpMap {"london"} = "uk";
$testHashpMap {"new york"} = "us";
$testHashpMap {"tokyo"} = "japan";

foreach $city ( keys %testHashpMap ) {
print STDERR "$city: $testHashpMap {$city} \n";
}

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.