How can I check if IP numbers are in the same subnet with Perl?
Can I use NetAddr::IP?
Seems like the Net::Subnet Perl module would do this. There's an example at that link I gave. If you don't want to use CPAN to get the module, both Debian and Ubuntu have a libnet-subnets-perl package.