use Socket qw( inet_aton inet_ntoa ); sub DottedQuadToLong { # Accepts triton.littlefish.ca # Accepts 24.72.30.83 # Accepts 407379539 # etc return unpack('N', inet_aton(shift)); } sub LongToDottedQuad { return inet_ntoa(pack('N', shift)); }