use strict; use warnings; use Regexp::Common qw( net ); open ( IPS, '<', "TEST_IPS.txt" ) || die "can't open IPS!"; open ( RULES, '<', "test_rules.txt" ) || die "can't open file!"; my %interesting_ips; while( ) { chomp; $interesting_ips{ $_ } = 1; } while( my $fw_line = ) { if ($fw_line =~ m{($RE{net}{IPv4})}g ) { print ( $fw_line); } }