$regex = '\w159\.230\.([01]?\d\d?|2[0-4]\d|25[0-4])\.([01]?\d\d?|2[0-4]\d|25[0-4])'; while () { if (m/$regex/os) { print PIXOUT $_; #### network-object 159.230.xxx.xxx 255.255.224.0 network-object 159.230.xxx.xxx 255.255.252.0 network-object 159.230.xxx.xxx 255.255.255.0 network-object host 159.230.xxx.xxx network-object host 159.230.xxx.xxx network-object host 159.230.xxx.xxx