in reply to Re^2: behavior of bitwise shift
in thread behavior of bitwise shift

I think you'll need to change
my $mask = "1" x ( 32 - $cidr ) . "0" x $cidr;
to
my $mask = "1" x $cidr . "0" x ( 32 - $cidr );
since /8 means a mask of 255.0.0.0 and not 255.255.255.0 which is /24.
But thanks a lot for this example - I was wondering how do that without a module (and could not figure how bitwise shifting should help).

Replies are listed 'Best First'.
Re^4: behavior of bitwise shift
by Taulmarill (Deacon) on Oct 25, 2004 at 15:17 UTC
    oh, yes, you are abviously right.
    i was so preoccupied remembering what pack/unpack modes i have to use that i just missed that.