Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Sifting through firewall rules using a script

by Discipulus (Canon)
on Dec 23, 2021 at 08:51 UTC ( [id://11139855]=note: print w/replies, xml ) Need Help??


in reply to Sifting through firewall rules using a script

Hello networkdude and welcome to the monastery and to the wonderful world ofperl!

Yes, beside strict and warnings (always use it!) I suggest you to adopt the lexical filehandle opening form: open(my $fh, "<", "input.txt")    or die "Can't open < input.txt: $!";

Then I suspect that you problem arises in line

if ($line =~ $IP) {

because all elements of @IPS end with a \n newline: you can chomp inside the foreach loop too, just before the pattern matching.

L*

PS as Tux noted you are already chomping, but the wrong array: use strict; use warnings; always :)

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found