Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Sifting through firewall rules using a script

by NetWallah (Canon)
on Dec 23, 2021 at 02:12 UTC ( [id://11139851]=note: print w/replies, xml ) Need Help??


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."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139851]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-19 07:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found