Hello,
I need some help with Perl script. And if you help me I will pay you $50 worth of amazon.com gift certificates.
I need small perl script. I believe it can be made by experienced programmer in 10-15 minutes.
I’m working on this domain query system. Script will be part of it. System is integrated with Windows.
This script need to analyze URL, and find host name in it.
Other program will POST URL to HTTP in this format.
http://www.mydomain.com/cgi-bin/script.cgi?"http://www.somedomain123.tld/directory/file.html"
So basically this script is getting a sting in this format:
"http://www.somedomain123.tld/directory/file.html"
1. It should find domain name in it without TLD (.com .net .cc etc)
in this case would be :
somedomain123
2. It should find TLD for that domain.
In this case would be tld.
3. Print it on HTML file.
…….
So there is two data item I interested in.
It should be prepared for long domains (67 characters). Subdomains should be ignored. E.g.: if comes:
"http://subdomain.somedomain123.co.uk/directory/file.html"
it would get domain name: somedomain123
and TLD : co.uk
.
I do some programming but I do not program Perl.
I have so idea how to do it.
So there is a algorithm:
"http://subdomain.somedomain123.co.uk/directory/file.html"
reachFor third (3) slash "/"
now you got ("http://subdomain.somedomain123.co.uk)
then read characters from right to left to first . (dot)
SELECT CASE
CASE first__characters = uk then
read second set of characters to next . (dot)
TLD= first_characters +. (dot)+ second_characters
CASE first_characters = br
read second set of characters to next . (dot)
TLD= first_characters +. (dot)+ second_characters
ELSE
TLD=first_characters
END CASE
So that’s for two TLD’s. I only need those two at this time. UK and BR.
And after that.
Following character string to next . (dot) will be domain name. ( somedomain123)
and now print TLD and domain name on HTML file.
Well that’s all.
If you stilt do not understand email me . rimvydas@karpavicius.net
If any of you will start coding, please post message in this forum so we will now that someone is working on it.
I will send you gift certificates as soon as I see program in action.
Big thanks.
Rimvis