This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove stale code from Thread.xs.
[perl5.git] / lib / hostname.pl
CommitLineData
463ee0b2
LW
1# From: asherman@fmrco.com (Aaron Sherman)
2
3sub hostname
4{
5 local(*P,@tmp,$hostname,$_);
6 if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
7 {
8 chop($hostname = $tmp[$#tmp]);
9 }
10 elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
11 {
12 chop($hostname = $tmp[$#tmp]);
13 }
14 else
15 {
16 die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
17 }
18 @tmp = ();
19 close P; # Just in case we failed in an odd spot....
20 $hostname;
21}
22
231;