in reply to Sifting through firewall rules using a script

As GrandFather says - "use strict;" would have told you that you are "chomp"ing the wrong variable name.

In addition (besides other minor nits), your regex to match the rules could result in many false positives.

I suggest

$line =~ /\b\Q$IP\E\b/
There are also optimizations possible depending on the number of IP addresses.
If it is < ~4k, you can combine them into a single regex with alternation, or change which file you choose to read into memory.

Feel free to ask specific (properly formatted) questions, using <code> tags for code (Writeup Formatting Tips).

                "If you had better tools, you could more effectively demonstrate your total incompetence."