| blib/lib/hostname.pl | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 6 | 8 | 75.0 |
| branch | 1 | 4 | 25.0 |
| condition | 2 | 12 | 16.6 |
| subroutine | 1 | 1 | 100.0 |
| pod | n/a | ||
| total | 10 | 25 | 40.0 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | # From: asherman@fmrco.com (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 | # | ||||||
| 11 | sub hostname | ||||||
| 12 | { | ||||||
| 13 | 1 | 1 | 716 | local(*P,@tmp,$hostname,$_); | |||
| 14 | 1 | 50 | 33 | 5699 | if (open(P,"hostname 2>&1 |") && (@tmp = ) && close(P)) |
||
| 0 | 33 | ||||||
| 0 | |||||||
| 0 | |||||||
| 15 | { | ||||||
| 16 | 1 | 48 | chop($hostname = $tmp[$#tmp]); | ||||
| 17 | } | ||||||
| 18 | elsif (open(P,"uname -n 2>&1 |") && (@tmp = ) && close(P)) |
||||||
| 19 | { | ||||||
| 20 | 0 | 0 | chop($hostname = $tmp[$#tmp]); | ||||
| 21 | } | ||||||
| 22 | else | ||||||
| 23 | { | ||||||
| 24 | 0 | 0 | die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n"; | ||||
| 25 | } | ||||||
| 26 | 1 | 10 | @tmp = (); | ||||
| 27 | 1 | 7 | close P; # Just in case we failed in an odd spot.... | ||||
| 28 | 1 | 60 | $hostname; | ||||
| 29 | } | ||||||
| 30 | |||||||
| 31 | 1; |