Commit | Line | Data |
463ee0b2 |
1 | # From: asherman@fmrco.com (Aaron Sherman) |
a6d71656 |
2 | # |
3 | # This library is no longer being maintained, and is included for backward |
4 | # compatibility with Perl 4 programs which may require it. |
d9591f87 |
5 | # This legacy library is deprecated and will be removed in a future |
6 | # release of perl. |
a6d71656 |
7 | # |
8 | # In particular, this should not be used as an example of modern Perl |
9 | # programming techniques. |
10 | # |
11 | # Suggested alternative: Sys::Hostname |
d9591f87 |
12 | |
13 | warn( "The 'hostname.pl' legacy library is deprecated and will be" |
14 | . " removed in the next major release of perl. Please use the" |
15 | . " Sys::Hostname module instead." ); |
16 | |
463ee0b2 |
17 | sub hostname |
18 | { |
19 | local(*P,@tmp,$hostname,$_); |
20 | if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P)) |
21 | { |
22 | chop($hostname = $tmp[$#tmp]); |
23 | } |
24 | elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P)) |
25 | { |
26 | chop($hostname = $tmp[$#tmp]); |
27 | } |
28 | else |
29 | { |
30 | die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n"; |
31 | } |
32 | @tmp = (); |
33 | close P; # Just in case we failed in an odd spot.... |
34 | $hostname; |
35 | } |
36 | |
37 | 1; |