Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Managing your IP space with Perl

by fokat (Deacon)
on Aug 15, 2002 at 19:02 UTC ( #190497=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP '127.0.0.1';
    
  2. or download this
    use NetAddr::IP;
    my $loopback = new NetAddr::IP '127.0.0.1', '255.0.0.0';
    my $rfc1918 = new NetAddr::IP '10.0.0.0/8';
    my $another = new NetAddr::IP '1.2.0.0/255.255.0.0';
    my $loopback2 = new NetAddr::IP 'loopback';
    
  3. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP('10.0.0.0/30');
    ...
      print "ip = $ip\n";
      $ip ++;
    }
    
  4. or download this
    ip = 10.0.0.0/30
    ip = 10.0.0.1/30
    ip = 10.0.0.2/30
    
  5. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP('10.0.0.0/30');
    print join(' ', @$ip), "\n";
    
  6. or download this
    10.0.0.1/32 10.0.0.2/32
    
  7. or download this
    use NetAddr::IP;
    
    ...
    10.0.64.0/18
    10.0.192.0/18
    10.0.160.0/19
    
  8. or download this
    use NetAddr::IP;
    
    print "My address space contains the following /24s:\n", 
        join("\n", NetAddr::IP->new('10.0.0.0/22')->split(24)), "\n";
    
  9. or download this
    use NetAddr::IP;
    
    print join(' ', NetAddr::IP->new('10.0.0.0/25')->wildcard());
    
  10. or download this
    use NetAddr::IP;
    
    ...
    10.128.0.41
    10.128.0.17
    10.128.0.19
    
  11. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    
  12. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    
  13. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://190497]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-01-18 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (213 votes). Check out past polls.

    Notices?