I take all the above back,...it worked. But only if I pass the domain name manually. $domain returned by Win32::DomainName is not correct (it is a valid domain) but its not the master domain.
Which brings me to the next question, how can obtain a list of available domains and how can I tell which is the master domain.
Many thanks once again.