in reply to Boolean logic with IP addresses

should do the trick... bitwise :)
(@segments) = split(/\./,$ip); foreach(@segments) { print unpack("B*",chr($_)); }
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
(tye)Re: Boolean logic with IP addresses
by tye (Sage) on May 17, 2001 at 18:59 UTC

    FYI, the "B" spec for unpack is "binary" as in a string of ASCII "1"s and "0"s. Take for example "192.168.10.1". Your code outputs:

    001100010011100100110010 001100010011011000111000 0011000100110000 00110001
    which isn't of much use for doing bit-wise stuff on IP addresses. It is the ASCII values of the characters from the strings "192", "168", "10", and "1" printed in binary notation.

            - tye (but my friends call me "Tye")