Unix and Linux Discussions Tagged with range |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
2 |
71,762 |
Shell Programming and Scripting |
|
|
|
1 |
4,911 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,379 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
5,227 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
5,728 |
UNIX for Advanced & Expert Users |
|
|
|
5 |
4,296 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
11,340 |
UNIX for Advanced & Expert Users |
|
|
|
0 |
3,504 |
Programming |
|
|
|
9 |
4,362 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
1,550 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
9,297 |
Shell Programming and Scripting |
|
|
|
1 |
4,337 |
Shell Programming and Scripting |
|
|
|
7 |
2,325 |
Shell Programming and Scripting |
|
|
|
4 |
3,642 |
Shell Programming and Scripting |
|
|
|
6 |
3,647 |
Shell Programming and Scripting |
|
|
|
1 |
3,542 |
Shell Programming and Scripting |
|
|
|
9 |
40,383 |
Shell Programming and Scripting |
|
|
|
9 |
6,725 |
Shell Programming and Scripting |
|
|
|
9 |
3,609 |
Shell Programming and Scripting |
|
|
|
2 |
5,890 |
Shell Programming and Scripting |
|
|
|
2 |
10,239 |
Shell Programming and Scripting |
|
|
|
4 |
2,421 |
Shell Programming and Scripting |
|
|
|
3 |
3,571 |
Shell Programming and Scripting |
|
|
|
4 |
16,108 |
Shell Programming and Scripting |
|
|
|
36 |
129,648 |
IP Networking |
|
|
|
11 |
15,171 |
UNIX for Dummies Questions & Answers |
|
|
|
9 |
5,854 |
Shell Programming and Scripting |
|
|
|
0 |
3,177 |
What is on Your Mind? |
|
|
|
8 |
4,116 |
Programming |
|
|
|
5 |
2,636 |
Shell Programming and Scripting |
|
|
|
2 |
2,446 |
Shell Programming and Scripting |
|
|
|
1 |
5,354 |
Shell Programming and Scripting |
|
|
|
3 |
2,424 |
Solaris |
|
|
|
2 |
4,038 |
Shell Programming and Scripting |
|
|
|
2 |
3,955 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,423 |
Solaris |
|
|
|
5 |
3,268 |
Shell Programming and Scripting |
|
|
|
2 |
4,568 |
UNIX and Linux Applications |
|
|
|
0 |
2,071 |
UNIX and Linux RSS News |
|
|
|
4 |
2,045 |
UNIX for Advanced & Expert Users |
Number::Range(3pm) User Contributed Perl Documentation Number::Range(3pm)
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.
SYNOPSIS
use Number::Range;
my $range = Number::Range->new("-10..10,12,100..120");
if ($range->inrange("13")) {
print "In range
";
} else {
print "Not in range
";
}
$range->addrange("200..300");
$range->delrange("250..255");
my $format = $range->range;
# $format will be '-10..10,12,100..120,200..249,256..300'
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.
RANGE FORMAT
The format used for range is pretty straight forward. To separate sections of ranges it uses a "," or whitespace. To create the range, it
uses ".." to do this, much like Perl's own binary ".." range operator in list context.
METHODS
new
$range = Number::Range->new("10..20","25..30");
Creates the range object. It will accept any number of ranges as its input.
addrange
$range->addrange("22");
This will also take any number of ranges as input and add them to the existing range.
delrange
$range->delrange("10");
This will also take any number of ranges as input and delete them from the existing range.
inrange
$range->inrange("26"); my @results = $range->inrange("27","200");
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 0's or 1's, depending if that one was true or false in the list position. If in scalar context, it will return a
single 1 if all are true, or a single 0 if one of them failed.
range
$format = $range->range; @numbers = $range->range;
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.
size
$size = $range->size;
This will return the total number of entries in the range.
EXPORT
None by default.
SEE ALSO
Number::Tolerant, Tie::RangeHash, and Array::IntSpan for similar modules.
AUTHOR
Larry Shatzer, Jr., <larrysh@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2004-12 by Larry Shatzer, Jr.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-06-20 Number::Range(3pm)