This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Abandon plans to change viacode's return of unassigned
[perl5.git] / lib / hostname.pl
CommitLineData
0111154e
Z
1warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n";
2
463ee0b2 3# From: asherman@fmrco.com (Aaron Sherman)
a6d71656
GS
4#
5# This library is no longer being maintained, and is included for backward
6# compatibility with Perl 4 programs which may require it.
d9591f87
S
7# This legacy library is deprecated and will be removed in a future
8# release of perl.
a6d71656
GS
9#
10# In particular, this should not be used as an example of modern Perl
11# programming techniques.
12#
13# Suggested alternative: Sys::Hostname
d9591f87 14
463ee0b2
LW
15sub hostname
16{
17 local(*P,@tmp,$hostname,$_);
18 if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
19 {
20 chop($hostname = $tmp[$#tmp]);
21 }
22 elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
23 {
24 chop($hostname = $tmp[$#tmp]);
25 }
26 else
27 {
28 die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
29 }
30 @tmp = ();
31 close P; # Just in case we failed in an odd spot....
32 $hostname;
33}
34
351;