I am not sure with perl as you need some way to revisit the same line, but in ruby it would look like:
Code:
ruby -ne '$_.scan(/[^.\s]+\.xyz\.com/).each{|x| puts x}' file
Hopefully this might help lead you to a perl solution
This does show that your original solution obviously won't work from the fact that you would need to print not only $1 on some lines.