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.