#!/usr/bin/perl use strict; use warnings; # initialize a hash with a list of key value pairs my %domains1 = ( 'com', 'commercial', 'edu', 'educational', 'org', 'non-profit' ); # same as above but using => in place of comma my %domains2 = ( 'com' => 'commercial', 'edu' => 'educational', 'org' => 'non-profit' ); # same as above but when using => keys do not have to be quoted my %domains3 = ( com => 'commercial', edu => 'educational', org => 'non-profit' ); # same as above but without extra spaces my %domains4 = ( com=>'commercial', edu=>'educational', org=>'non-profit' ); print "domains1:\n"; for my $key ( keys %domains1 ) { print "\t$key $domains1{$key}\n"; } print "domains2:\n"; for my $key ( keys %domains2 ) { print "\t$key $domains2{$key}\n"; } print "domains3:\n"; for my $key ( keys %domains3 ) { print "\t$key $domains3{$key}\n"; } print "domains4:\n"; for my $key ( keys %domains4 ) { print "\t$key $domains4{$key}\n"; }