Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Use of uninitialized value $i in bitwise and (&) at <Netmask.pm>

by soonix (Canon)
on Dec 18, 2017 at 12:44 UTC ( [id://1205786]=note: print w/replies, xml ) Need Help??


in reply to Use of uninitialized value $i in bitwise and (&) at <Netmask.pm>

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.

Replies are listed 'Best First'.
Re^2: Use of uninitialized value $i in bitwise and (&) at <Netmask.pm>
by dotowwxo (Acolyte) on Dec 19, 2017 at 02:37 UTC
    Hello, will note down the tip for sure! However, its not ideal as the same error still occurs to me :( Appreciate the effort dou :) Thank you :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found