Net::IPAddress::Minimal - IP string to number and back
version 0.05
This module converts IPv4 strings to integer IP numbers and vice versa.
It's built to be used as quickly and easily as possible, which is why you can just simply use the invert_ip function.
invert_ip
It recognizes whether you have an IPv4 string or a number and converts it to the other form.
Here's a sample script:
use Net::IPAddress::Minimal ('invert_ip'); my $input_string = shift @ARGV; my $output = invert_ip( $input_string ); print "$output\n";
Three functions can be exported:
num_to_ip
ip_to_num
Gets an IPv4 string or an IP number and converts it to the other form.
my $ip_num = invert_ip( '10.200.10.130' ); # $ip_str = 180882050 my $ip_num = invert_ip( 180882050 ); # $ip_str = '10.200.10.130';
Gets an IP number and returns an IPv4 string.
my $ip_num = num_to_ip( 3232235778 ); # $ip_str = '192.168.1.2';
Gets a IPv4 string and returns the matching IP number.
my $ip_num = ip_to_num( '212.212.212.212' ); # $ip_num = 3570717908
Checks the structure of the input string and returns flags indicating whether it's an IPv4 string, and IP number or something else (which is an error).
We encourage you to open bugs on the Github Issues page:
http://github.com/Tlousky/net-ipaddress-minimal/issues.
Tamir Lousky <tlousky@cpan.org> Sawyer X <xsawyerx@cpan.org>
This software is copyright (c) 2010 by Tamir Lousky.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::IPAddress::Minimal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::IPAddress::Minimal
CPAN shell
perl -MCPAN -e shell install Net::IPAddress::Minimal
For more information on module installation, please visit the detailed CPAN module installation guide.