Translating hostnames into IP addresses : IP Address « Network « Perl






Translating hostnames into IP addresses

   



#!/usr/bin/perl


use Socket;

my $packed_address = gethostbyname("localhost");
unless ($packed_address) {
    print "$_ => ?\n";
    next;
}
my $dotted_quad    = inet_ntoa($packed_address);
print "$_ => $dotted_quad\n";

   
    
    
  








Related examples in the same category

1.Translating IP addresses into hostnames