in reply to My network range

Where you have

$calculated = 2**(32 - $VALUE[1]);
you might try this instead (especially if this code gets performed over and over and ove...) :
$calculated = 1 << (32 - $VALUE[1]);

A bit-wise shift, especially in the case where you're dealing with powers of two, would likely be much less computationally expensive that exponentiation via multiplication. (That's my guess-can someone verify this?)