Perl : how to match non-empty string that has no spaces

Hi Everyone,

I am looking for neat way to grep a non-empty string that basically contains a hostname, which might be in FWDN form or without the domain, for example:

hostname.internal.domainname.net

The file I am parsing contains blan lines (^$) and also series of "-" which in other places are used as separator (-----------------------).

As you of course know hyphen ("-") may well occur in a hostname.

if (/\S/) - is not good as it catches "--------------" too
if (! /\s/) - is not good either for the same reason

I was playing with regexes like: /[A-Za-z0-9.-]+/ but couldn't get what I actually need. That matched series of hyphens either. I need a regex that would allow for hyphens but denied "hyphens only". In other words hyphens are permitted but only when there are other letters as well.

I was able to get around my problem using two or three if... tests but this problem is still sitting in the back of my head.

I think I made my explanation unclear... apologies for that. Be sure I'll be seeking for answer myself too:)
Kind regards to Everyone.

Try:

!/^-+$/&&/[A-Za-z0-9.-]+/

Hi togr,

Another one to try:

m/-/ && m/[^-\s]/

Regards,
Birei