BadMojo has asked for the wisdom of the Perl Monks concerning the following question:

Quick qestion or at lest I think this should be a quick one! How would I go about finding the hostname, computername, of the computer that a script is currently running on? Thank you in advanced for any help.

BadMojo
mford@badmojo.biz
www.badmojo.biz
!=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-!
When something works but shouldn't thats BADMOJO baby.

20050505 Edit by Corion: Changed title from 'perl32'

Replies are listed 'Best First'.
Re: finding my hostname
by gellyfish (Monsignor) on May 05, 2005 at 12:10 UTC

    This is dicussed in the FAQ

    /J\

      Thank you sorry I didn't look there first!

      BadMojo
      mford@badmojo.biz
      www.badmojo.biz
      !=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-!
      When something works but shouldn't thats BADMOJO baby.

Re: finding my hostname
by tlm (Prior) on May 05, 2005 at 13:34 UTC

    Also, in addition to the method given in the FAQ gellyfish cited, if the script in question is a CGI script running under Apache/Unix (yes, a lot of ifs), then you can look at the variables $ENV{ HTTP_HOST } and $ENV{ SERVER_ADDR } for the server name and IP address, respectively.

    the lowliest monk

      But since you'd of course be using CGI you could just use virtual_host and/or server_name instead of mucking with the environment directly.