Merge branch 'master' of http://repo.or.cz/r/msysgit into devel
[msysgit/historical-msysgit.git] / lib / perl5 / 5.6.1 / hostname.pl
blob63eea8fee455608793535a49847d22cf80f8adf5
1 # From: asherman@fmrco.com (Aaron Sherman)
3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
6 # In particular, this should not be used as an example of modern Perl
7 # programming techniques.
9 # Suggested alternative: Sys::Hostname
11 sub hostname
13 local(*P,@tmp,$hostname,$_);
14 if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
16 chop($hostname = $tmp[$#tmp]);
18 elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
20 chop($hostname = $tmp[$#tmp]);
22 else
24 die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
26 @tmp = ();
27 close P; # Just in case we failed in an odd spot....
28 $hostname;