#!/usr/bin/perl use strict; use warnings; use Net::Netmask; my $filename = 'testingIP.txt'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; my $block = Net::Netmask->new("192.168.1.0/27"); while (my $row = <$fh>){ my @row = $row; for (my $i=0; $i < scalar(@row); $i++){ if ($block->match($row[$i])){ print "IP address: $row[$i] is inside $block\n"; } else{ print "IP address: $row is not inside $block\n"; } } }