Marco sends us some code that he wrote, back in the far off days of 2003. He wrote some code to handle network addresses. Unfortunately, it never quite worked. Specifically it could only handle addresses in the /24
subnet.
Now, this was written in Perl, so you know it involves regexes.
@IPstart = split(/\./,$start);
@IPend = split(/\./,$end);
&Check_Start_and_EndIP;
# converts "short" (dotted) IPs to "long" (undotted) IPs
$IPstart = (($IPstart[0]*16777216)+($IPstart[1]*65536)+($IPstart[2]*256)+$IPstart[3]);
$IPend = (($IPend[0]*16777216)+($IPend[1]*65536)+($IPend[2]*256)+$IPend[3]);
if($IPend < $IPstart) { die "Can't scan backwards"; }
$CountIp = $IPstart;
$EndIp = $IPend+1;
while($CountIp ne $EndIp)
{
@Class = &GetIP($CountIp);
push(@targetlist, "$Class[1]\.$Class[2]\.$Class[3]\.$Class[4]");
$CountIp++;
}
This, by the way, is Marco's attempt to fix the broken code. As Marco puts it: "I am not a coder. I 'fix' things."