Net::Silk::CIDR - SiLK IP CIDR class
use Net::Silk::CIDR; my $r = Net::Silk::CIDR->new('1.1.1.0' => 27); # or "1.1.1.0/27" $r->contains("1.1.1.2"); # true print "$r\n"; # 1.1.1.0/27 print join('/', $r->ip, $r->prefix), "\n"; # 1.1.1.0/27 print join('/', @$r, "\n"; # 1.1.1.0/27 my $size = $r->cardinality; # 32 use Net::Silk::IPSet; my $s = Net::Silk::IPSet->load("my.set"); my $iter = $s->iter_cidr; while (my $r = $iter->()) { ... # $r is a Net::Silk::CIDR } use Net::Silk::Pmap; my $s = Net::Silk::Pmap->load("my.pmap"); my $iter = $s->iter_cidr; while (my($k, $v) = each %$s) { ... # $k is a Net::Silk::CIDR }
Net::Silk::CIDR is a lightweight wrapper around a CIDR block specified by an IP and prefix bits. It is returned by iterators in Net::Silk::IPSet, Net::Silk::Pmap, and Net::Silk::IPWildcard.
Net::Silk::CIDR
Returns a new Net::Silk::CIDR object represented by the given IP base and prefix bits. The two values can be provided either as separate arguments, in an array ref, or a string representation.
Return the base of this CIDR as a Net::Silk::IPAddr. This can alternately be accessed via $r->[0].
$r->[0]
Return the prefix bits of this CIDR. This can alternately be accessed via $r->[1].
$r->[1]
Return the first address in the CIDR range, same as ip().
ip()
Return the last address in the CIDR range.
Return the number of elements in this block.
Return whether or not the given item is contained in this block.
Returns a Net::Silk::Range representing this block.
Return a string in the form of "ip/prefix". This method gets invoked automatically when the block is used in string context.
"ip/prefix"
Return a sub ref that iterates over all elements of this block. Treating the object like a filehandle <$r> yields the same results.
<$r>
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::Range, 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 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.
To install Net::Silk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Silk
CPAN shell
perl -MCPAN -e shell install Net::Silk
For more information on module installation, please visit the detailed CPAN module installation guide.