Here is a Perl Problem that was posed to me. I was given one day time to solve.  Unfortunately I did not know enough Perl to do it. And  sadly, I did not get selected.  However I wish to share this question with all. Please pose your answers or programs on this forum for the benefit of all friends. Submitted by  ilangocal.

Here is the link for the full questions in exforsys forum, see if you can answer ttp://

Showing Answers 1 - 1 of 1 Answers

Vadivel raja

  • Dec 7th, 2005

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")

 (name,domain) = split(/@/, myvar[i])

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]))
  query(update domain_count_tbl set count=mylist[$key] where domain="$key")

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions