Mega Code Archive

 
Categories / Perl / Hash
 

Associative arrays are indexed by string values

#!/usr/local/bin/perl -w my %cities = ("Toronto" => "East", "Calgary" => "Central", "Vancouver" => 'West'); for $key (keys %cities) {    print "Key: $key Value: $cities{$key} \n"; }