in reply to Host IP address

AFAIK, DOCUMENT_ROOT will only print out the absolute path to your, well, document root. This will not print the server's hostname. So I presume you have a directory called 'www.myhostname.com'. (E.g. /usr/local/www/www.myhostname.com/).

Of course you could use a DNS lookup (as suggested) on that portion of the path, but I tend to dislike that, if this script is only used on a few directories of yourself with fixed ip addresses. Each time you run the script, the DNS query will be performed and the script will have to wait for it's output. This can be time consuming, not to mention the bandwidth you waste ;)

I would suggest to simply use the IP address instead of the $ENV{DOCUMENT_ROOT} if possible, so use something like:
my $ip = "123.123.123.123"; chdir("$ip/dir1/dir2") || die "Can't open = $!\n";
If you have multiple directories (hostnames), you might want to create a hash with all the ip addresses you use.
%ip_address = ('www.myhostname.com','123.123.123.123','www.herhostname +.net','456.456.456.456');
So you can look it up way faster ($ip_address{'www.myhostname.com'} will give "123.123.123.123").

This, of course, is handy for simple scripts with just a few hostnames and fixed ip addresses. If you have a lot, it can be time consuming to enter it all, so forget about bandwidth and use the DNS lookup, as suggested by others ;)

--
b10m