#!/usr/bin/perl -w

use strict;

my %ip_to_host = ("134.153.48.1", "garfield", "134.153.48.2", "mirror",
	 "134.153.48.3", "phobos", );

$ip_to_host{"134.153.48.4"} = "deimos";
$ip_to_host{"134.153.48.10"} = "irma";

while (my ($ip, $host) = each %ip_to_host) {
	print "Hostname $host has IP address $ip\n";
}
print "\n";
delete $ip_to_host{"134.153.48.2"};	# Get rid of 'mirror' host.

# Display the hosts again, this time in sorted order.  Note
# that the sorting is lexicographic.  So host irma's IP
# address appears after garfield but before phobos
#
for (sort keys %ip_to_host) {
	print "Hostname $ip_to_host{$_} has IP address $_\n";
}

my %host_to_ip = reverse %ip_to_host;
printf "\nGarfield has ip address $host_to_ip{'garfield'}\n";
