Depending on the parts you have already written and the functionality you need, Mozilla::PublicSuffix might help you to determine what is "a domain" and what is "a hostname in a domain".
If your question is only about string manipulation, have you considered using split on a dot and taking the first result?
my @parts = split /\./, $input;
In reply to Re: Steps to get a substring from a string
by Corion
in thread Steps to get a substring from a string
by shroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |