shell or perl script using grep and regex

Hi,

I have file stored in a directory containing information about subnet mask and next hop address in the following format

10.1.1.0/16, 255.255.0.0, 10.1.1.1
10.1.2.0/16, 255.255.0.0,10.1.2.1

here 10.1.1.0/16 represent range of ip address 10.1.1.1-10.1.1.16

given say an IP address 10.1.1.5 I need to write a script to get sub net Mask and next hop. What is the best way using grep and regex

regexes cannot understand ip/subnet ranges because they have no concept of numbers, let alone arithmetic.