i think the problem is straight forward and should be very simple to write a perl program for the same, below is the program. i havent run it to check if it works fine. comments are welcome
1. Assuming table 1 having the address has a structure
address_tbl (mailaddress char(255))
2. Assuming table 2 having the count of domains has a structure
domain_count_tbl (domain char(255), count int)
=========================================================================================
@maillist = query("select * from address_tbl")
for(i=0;i<scalar(@maillist;i++)
{
(name,domain) = split(/@/, myvar[i])
mylist[domain]++
}
foreach $key (keys %mylist)
{
@res = query("select 1 from domain_count_tbl where domain=$key")
if (scalar(@res) == 0 )
{
query(insert into domain_count_tbl values("$key",mylist[$key]))
}
else
{
query(update domain_count_tbl set count=mylist[$key] where domain="$key")
}
}