use Win32::NetAdmin; my $hostname = Win32::NodeName();
my $ref = {}; my $hostid; if( Win32::NetAdmin::GetTransports("\\\\$hostname", $ref) ) { foreach my $trans (keys %{$ref}) { if( $ref-> {$trans}->{'transport_name'} =~ /NetBT_/) { $hostid = $ref-> {$trans}->{'transport_address'}; $hostid = uc( $hostid ); last; } } } print"hostname = $hostname\n"; print "hostid = $hostid\n";
use Sys::Hostname; my $host = hostname; my $name = gethostbyname($host); my $ip_addr = inet_ntoa($name); print "Host name: $host\n";
|