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";
}

Recent comments
6 days 19 hours ago
2 weeks 4 days ago
4 weeks 3 hours ago
4 weeks 2 days ago
4 weeks 3 days ago
4 weeks 5 days ago
29 weeks 1 day ago
29 weeks 4 days ago
29 weeks 4 days ago
30 weeks 12 hours ago