Net::Silk::Range - SiLK IP and proto/port range class
use Net::Silk::Range;
my $r = Net::Silk::Range->new('1.1.1.1' => '1.255.255.255');
# or could have used "1.1.1.1-1.255.255.255"
$r->contains("1.1.1.2"); # true
print "$r\n"; # 1.1.1.1-1.255.255.255
print join(' ', $r->first, $r->last), "\n"; # 1.1.1.1 1.255.255.255
print join(' ', @$r, "\n"; # 1.1.1.1 1.255.255.255
my $size = $r->cardinality; # 16711423
use Net::Silk::IPSet;
my $s = Net::Silk::IPSet->load("my.set");
my $iter = $s->iter_ranges;
while (my $r = $iter->()) {
... # $r is a Net::Silk::Range
}
use Net::Silk::Pmap;
my $s = Net::Silk::Pmap->load("my.pmap");
my $iter = $s->iter_ranges;
while (my($k, $v) = each %$s) {
... # $k is a Net::Silk::Range
}
Net::Silk::Range
is a lightweight wrapper around an IP block specified by a first and last value. It is returned by iterators in Net::Silk::IPSet, Net::Silk::Pmap, and Net::Silk::IPWildcard.
Returns a new Net::Silk::Range
object represented by the given low and high values. The two values can be provided either as separate arguments, an array ref, or a string representation. The values are Net::Silk::IPAddr or Net::Silk::ProtoPort objects or their string representations.
Return the first value in the range. This can alternately be accessed via $r->[0]
.
Return the last value in the range. This can alternately be accessed via $r->[1]
.
Return the number of elements in this range.
Return whether or not the given item is contained in this range.
Returns an array or array ref (depending on context) of Net::Silk::CIDR blocks are covered by this range.
Return a string in the form of "first-last"
. This method gets invoked automatically when the range is used in string context.
Return a sub ref that iterates over all elements of this range. Treating the range like a filehandle <$r>
yields the same results.
The following operators are overloaded:
<> ""
eq ==
ne !=
cmp <=>
Net::Silk, Net::Silk::RWRec, Net::Silk::IPSet, Net::Silk::Bag, Net::Silk::Pmap, Net::Silk::IPWildcard, Net::Silk::CIDR, Net::Silk::IPAddr, Net::Silk::TCPFlags, Net::Silk::ProtoPort, Net::Silk::File, Net::Silk::Site, silk(7)
Copyright (C) 2016 by Carnegie Mellon University
Use of the Net-Silk library and related source code is subject to the terms of the following licenses:
GNU General Public License (GPL) Rights pursuant to Version 2, June 1991 Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013
NO WARRANTY
See GPL.txt and LICENSE.txt for more details.