I don't think that's perl - it's how gethostbyname() works. "localhost" should always resolve to 127.0.0.1. To get your actual IP address you'd have to use gethostbyname() with the name that maps to your current IP address, which will normally be set through dhcp if it is dynamic.