.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 "Number::Range 3pm" .TH Number::Range 3pm "2022-06-16" "perl v5.34.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" Number::Range \- Perl extension defining ranges of numbers and testing if a number is found in the range. You can also add and delete from this range. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Number::Range; \& \& my $range = Number::Range\->new("\-10..10,12,100..120"); \& if ($range\->inrange("13")) { \& print "In range\en"; \& } else { \& print "Not in range\en"; \& } \& $range\->addrange("200..300"); \& $range\->delrange("250..255"); \& my $format = $range\->range; \& # $format will be \*(Aq\-10..10,12,100..120,200..249,256..300\*(Aq .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Number::Range will take a description of a range, and then allow you to test on if a number falls within the range. You can also add and delete from the range. .SS "\s-1RANGE FORMAT\s0" .IX Subsection "RANGE FORMAT" The format used for range is pretty straight forward. To separate sections of ranges it uses a \f(CW\*(C`,\*(C'\fR or whitespace. To create the range, it uses \f(CW\*(C`..\*(C'\fR to do this, much like Perl's own binary \f(CW\*(C`..\*(C'\fR range operator in list context. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" .IP "new" 4 .IX Item "new" .Vb 1 \& $range = Number::Range\->new("10..20","25..30","100"); .Ve .Sp Creates the range object. It will accept any number of ranges as its input. .IP "addrange" 4 .IX Item "addrange" .Vb 1 \& $range\->addrange("22"); .Ve .Sp This will also take any number of ranges as input and add them to the existing range. .IP "delrange" 4 .IX Item "delrange" .Vb 1 \& $range\->delrange("10"); .Ve .Sp This will also take any number of ranges as input and delete them from the existing range. .IP "inrange" 4 .IX Item "inrange" .Vb 1 \& $range\->inrange("26"); my @results = $range\->inrange("27","200"); .Ve .Sp This will take one or more numbers and check if each of them exists in the range. If passed a list, and in array context, it will return a list of \f(CW0\fR's or \f(CW1\fR's, depending if that one was true or false in the list position. If in scalar context, it will return a single \f(CW1\fR if all are true, or a single \f(CW0\fR if one of them failed. .IP "range" 4 .IX Item "range" .Vb 1 \& $format = $range\->range; @numbers = $range\->range; .Ve .Sp Depending on context this will return either an array of all the numbers found in the range, for list context. For scalar context it will return a range string. .IP "size" 4 .IX Item "size" .Vb 1 \& $size = $range\->size; .Ve .Sp This will return the total number of entries in the range. .IP "rangeList" 4 .IX Item "rangeList" .Vb 1 \& @rangeList = $range\->rangeList; .Ve .Sp Returns the range as an array list where each element in the list is an array representing the start and stop points of a range. Single element ranges are returned as single element arrays with only on indice. .Sp [ [10,20], [25,30], [100] ] .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" None by default. .SH "SEE ALSO" .IX Header "SEE ALSO" Number::Tolerant, Tie::RangeHash, and Array::IntSpan for similar modules. .SH "AUTHOR" .IX Header "AUTHOR" Larry Shatzer, Jr., .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2004\-14 by Larry Shatzer, Jr. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.