Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Regexp: Private IP Addresses

by ikegami (Pope)
on Aug 25, 2009 at 19:25 UTC ( #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
Node Status?
node history
Node Type: note [id://791164]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (18)
As of 2014-08-01 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (33 votes), past polls