NAME

Net::IPAddress::Minimal - IP string to number and back

VERSION

version 0.05

SYNOPSIS

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.

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";

EXPORT

Three functions can be exported:

  • invert_ip

  • num_to_ip

  • ip_to_num

SUBROUTINES/METHODS

invert_ip

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';

num_to_ip

Gets an IP number and returns an IPv4 string.

my $ip_num = num_to_ip( 3232235778 );
#  $ip_str = '192.168.1.2';

ip_to_num

Gets a IPv4 string and returns the matching IP number.

my $ip_num = ip_to_num( '212.212.212.212' );
#  $ip_num = 3570717908

test_string_structure

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).

BUGS

We encourage you to open bugs on the Github Issues page:

http://github.com/Tlousky/net-ipaddress-minimal/issues.

AUTHORS

Tamir Lousky <tlousky@cpan.org>
Sawyer X <xsawyerx@cpan.org>

COPYRIGHT AND LICENSE

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.