#!/usr/bin/perl -w use strict; my $hostfile = "/etc/hosts"; my %hosts = (); open FILE, "<", "$hostfile" || die "Cannot open $hostfile $!"; while () { next if /^\s*#/ ; # skip comments chomp; my ($key, $value) = split (" ", $_); $hosts{$key} = $value; } close FILE;