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

Re: Regexp: Private IP Addresses

by ikegami (Patriarch)
on Aug 25, 2009 at 19:25 UTC ( [id://791164]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub is_private {
        my ($packed_ip) = @_;
    ...
            )
        }x;
    }
    
  2. or download this
    use strict;
    use warnings;
    ...
    
    print("got:    $result\n");
    print("expect: ", "0110"x3, "\n");
    
  3. or download this
    got:    011001100110
    expect: 011001100110
    
  4. or download this
    sub is_private {
        my ($packed_ip) = @_;
    ...
            || ($packed_ip & "\xFF\xF0\x00\x00") eq "\xAC\x10\x00\x00"
            || ($packed_ip & "\xFF\xFF\x00\x00") eq "\xC0\xA8\x00\x00";
    }
    
  5. or download this
    sub is_private {
        my $nummy_ip = unpack('N', shift);
    ...
            || ($nummy_ip & 0xFFF00000) == 0xAC100000   # 172.16.0.0/12
            || ($nummy_ip & 0xFFFF0000) == 0xC0A80000;  # 192.168.0.0/16
    }
    
  6. or download this
    use Inline CPP => <<'__EOI__';
    
    ...
        }
    
    __EOI__
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found