Created
August 12, 2016 14:32
-
-
Save adkinss/d071bc4805b9dc0f28cd450c5e3b9c4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# Converts an integer number representing an IP back into an IP address string | |
use strict; | |
sub ip_to_int ($) | |
{ | |
my $addr = shift @_; | |
return unpack("N", pack("C4", split(/\./, $addr))); | |
} | |
sub int_to_ip ($) | |
{ | |
my $addr = shift @_; | |
return join(".", unpack("C4", pack("N", $addr))); | |
} | |
foreach (@ARGV) { | |
print "$_ = ", ip_to_int($_), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment