Apart from using the Sys::Hostname module as recommended by Corion, you could also check to see whether the shell environment in which perl is operating contains a "HOST" variable already set for you:
That works for me when running on a linux (debian) desktop machine (but not on a macosx 10.7 laptop). For the sake of portability, I'd go with the module.