source: for-distributions/trunk/bin/windows/perl/lib/hostname.pl@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

File size: 727 bytes
Line 
1# From: [email protected] (Aaron Sherman)
2#
3# This library is no longer being maintained, and is included for backward
4# compatibility with Perl 4 programs which may require it.
5#
6# In particular, this should not be used as an example of modern Perl
7# programming techniques.
8#
9# Suggested alternative: Sys::Hostname
10#
11sub hostname
12{
13 local(*P,@tmp,$hostname,$_);
14 if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
15 {
16 chop($hostname = $tmp[$#tmp]);
17 }
18 elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
19 {
20 chop($hostname = $tmp[$#tmp]);
21 }
22 else
23 {
24 die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
25 }
26 @tmp = ();
27 close P; # Just in case we failed in an odd spot....
28 $hostname;
29}
30
311;
Note: See TracBrowser for help on using the repository browser.