in reply to Bit fiddling madness
I notice that Net/CIDR/Lookup.pm has "use integer"
According to Shift Operators:
Note that both << and >> in Perl are implemented directly using << and >> in C. If use integer (see Integer Arithmetic) is in force then signed C integers are used."This means that right shifts will be sign extended. Anything with the msb set will be sign extended and remain negative.
$ perl -E 'use integer; say 0x80000000 >> 31' -1
RichardK's suggestion above would avoid this issue.
In Section
Seekers of Perl Wisdom