This should work too, and is probably better because of
simplicity.
For those wondering, what this code effectively does is
compare the network numbers of the $addr and the $base
specification by shifting the host bits off the end
(with the >> operator). What I was doing was
building a range specification, which given the task, is
really overkill.