#!/usr/local/bin/perl -w

use strict;
use warnings;
use IO::File;

my $stdout=*STDOUT{'IO'};
$stdout->autoflush(1);

my $input;
if (@ARGV) {
  $input=IO::File->new();
  $input->open($ARGV[0], 'r')
      or die('unable to open ', $ARGV[0], ': ', $!, "\n");
} else {
  $input=*STDIN{'IO'};
}

my %data=();
while (defined(my $line=$input->getline())) {
  next unless $line=~s/^=//;
  my ($name, $addr)=split(/:/, $line);
  if (exists($data{$addr})) {
    $stdout->print('duplicate host: ', $data{$addr}, ': ', $name, "\n");
  } else {
    $data{$addr}=$name;
  }
}
