Convert elements of @blocklist,and the "one IP address", into NetAddr::IP objects.
Those objects support the method:
$me->contains($other)
#Returns true when $me completely contains $other. False is returned
+ otherwise
# and undef is returned if $me and $other are of different versions.
#Note that $me and $other must be NetAddr::IP objects.
You can then use grep to filter the list of objects, limiting them to thost where the condition is TRUE.
"For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken
| [reply] [d/l] |
Reading Don't Use Regular Expressions To Parse IP Addresses! first:
1) Convert the dotted-quad forms to integers.
2) Select the appropriate netmask.
3) Logical AND with the netmask to generate a subnet.
4) Exclusive -or two subnets to compare them.
If you think of the subnets as bitmasks, comparing them with host addresses is trivial.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] [d/l] |