in reply to Re: Subnet Overlap
in thread Subnet Overlap
This is quite untrue and more indicative of your own misunderstanding of how Perl deals with strings
Actually, the OP was correct. split does return strings, and he does need to force them into numbers before using & on them.
my $i = my $x = (split(/\./, '205.0.0.0'))[0]; my $j = my $y = (split(/\./, '123.0.0.0'))[0]; my $ij = $i & $j; $x += 0; $y += 0; my $xy = $x & $y; print("$i & $j = $ij\n"); # 205 & 123 = 001 print("$x & $y = $xy\n"); # 205 & 123 = 73
Your example shows that +, expecting a number, will convert the string to a number, but the OP is using & which is acts differently for strings and numbers.
The OP was wrong in calling it a bug, though.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Subnet Overlap
by bfarley (Initiate) on Aug 22, 2007 at 03:07 UTC |