|
ホスト情報の一覧を出力するCGIです。 …とはいえ、iswebの環境では、ホンモノの情報は得られませんが…。 動作例
ここを押すと、実行結果がわかります。↓ ソースコード
#!/usr/local/bin/perl
use CGI;
use strict;
my $cgi = new CGI;
print $cgi->header, $cgi->start_html('Get Host Entry');
print "<p><table border=\"1\">\n";
print "<tr><th>Name</th><th>Aliases</th><th>Type</th>";
print "<th>Length</th><th>Addresses</th></tr>\n";
my ($n, $a, $t, $l, @s, $sp, @sa);
sethostent(1);
while(($n, $a, $t, $l, @s) = gethostent()) {
print "<tr><td>$n</td><td>$a</td><td>$t</td>";
print "<td>$l</td><td>";
@sa = ();
foreach $sp (@s) {
my $l = join(".", unpack("C*", $sp));
push(@sa, $l);
}
print join(",", @sa) . "</td></tr>\n";
}
endhostent();
print "</table></p>\n";
print $cgi->end_html;
|
▼ 個人的宣伝
|