#! /usr/bin/perl -w

use strict;
use warnings;

my $domain = '\@(([-a-z0-9]+\.)*[a-z]+)';

my $file = shift @ARGV;
open FILE, $file;

my $domains = {};
while (my $line = <FILE>) {
    if ($line =~ /$domain/oi) {
        $domains->{$1}++;
    }
}

foreach my $key (keys %$domains) {
    print $key, "\t", $domains->{$key}, "\n";
}
