.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Array::IntSpan::IP 3pm" .TH Array::IntSpan::IP 3pm "2020-03-30" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Array::IntSpan::IP \- a Module for arrays using IP addresses as indices .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Array::IntSpan::IP; \& \& my $foo = Array::IntSpan::IP\->new([\*(Aq123.45.67.0\*(Aq, \*(Aq123.45.67.255\*(Aq, \*(AqNetwork 1\*(Aq], \& [\*(Aq123.45.68.0\*(Aq, \*(Aq123.45.68.127\*(Aq, \*(AqNetwork 2\*(Aq], \& [\*(Aq123.45.68.128\*(Aq, \*(Aq123.45.68.255\*(Aq, \*(AqNetwork 3\*(Aq]); \& \& print "The address 123.45.68.37 is on network ".$foo\->lookup("\e173\e105\e150\e45").".\en"; \& unless (defined($foo\->lookup(((123*256+45)*256+65)*256+67))) { \& print "The address 123.45.65.67 is not on a known network.\en"; \& } \& \& print "The address 123.45.68.177 is on network ".$foo\->lookup("123.45.68.177").".\en"; \& \& $foo\->set_range(\*(Aq123.45.68.128\*(Aq, \*(Aq123.45.68.255\*(Aq, \*(AqNetwork 4\*(Aq); \& print "The address 123.45.68.177 is now on network ".$foo\->lookup("123.45.68.177").".\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`Array::IntSpan::IP\*(C'\fR brings the advantages of \f(CW\*(C`Array::IntSpan\*(C'\fR to \s-1IP\s0 address indices. Anywhere you use an index in \f(CW\*(C`Array::IntSpan\*(C'\fR, you can use an \s-1IP\s0 address in one of three forms in \f(CW\*(C`Array::IntSpan::IP\*(C'\fR. The three accepted forms are: .IP "Dotted decimal" 4 .IX Item "Dotted decimal" This is the standard human-readable format for \s-1IP\s0 addresses. The conversion checks that the octets are in the range 0\-255. Example: \&\f(CW\*(Aq123.45.67.89\*(Aq\fR. .IP "Network string" 4 .IX Item "Network string" A four character string representing the octets in network order. Example: \f(CW"\e173\e105\e150\e131"\fR. .IP "Integer" 4 .IX Item "Integer" A integer value representing the \s-1IP\s0 address. Example: \&\f(CW\*(C`((123*256+45)*256+67)*256+89\*(C'\fR or \f(CW2066563929\fR. .PP Note that the algorithm has no way of distinguishing between the integer values 1000 through 9999 and the network string format. It will presume network string format in these instances. For instance, the integer \f(CW1234\fR (representing the address \f(CW\*(Aq0.0.4.210\*(Aq\fR) will be interpreted as \f(CW"\e61\e62\e63\e64"\fR, or the \s-1IP\s0 address \f(CW\*(Aq49.50.51.52\*(Aq\fR. This is unavoidable since Perl does not strongly type integers and strings separately and there is no other information available to distinguish between the two in this situation. I do not expect that this will be a problem in most situations. Most users will probably use dotted decimal or network string notations, and even if they do use the integer notation the likelihood that they will be using the addresses \f(CW\*(Aq0.0.3.232\*(Aq\fR through \f(CW\*(Aq0.0.39.15\*(Aq\fR as indices is relatively low. .SH "METHODS" .IX Header "METHODS" .SS "ip_as_int" .IX Subsection "ip_as_int" The class method \f(CW\*(C`Array::IntSpan::IP::ip_as_int\*(C'\fR takes as its one parameter the \s-1IP\s0 address in one of the three formats mentioned above and returns the integer notation. .SH "AUTHOR" .IX Header "AUTHOR" Toby Everett, teverett@alascom.att.com