In addition to the advice by others:
Something is wrong with
if ($block->match($row[$i])){
print "IP address: $row[$i] is inside $block\n";
}
else{
print "IP address: $row is not inside $block\n";
}
in the "if" branch, you print
$row[$i], while in the "else" branch, you print
$row - no wonder your output contains blatant lies as e.g. "IP address: 192.168.1.1 is not inside 192.168.1.0/27" …
I suggest something like
print "IP address: $row[$i] is ";
if ($block->match($row[$i])){
print "inside";
}
else{
print "outside";
}
print " $block\n";
Of course, this isn't ideal either, but less error prone.