Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Need to calculate IP address

by johngg (Canon)
on Dec 29, 2017 at 00:39 UTC ( [id://1206381]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -MSocket -E '
    do {
    ...
       } for qw{ 10.1.1.5 10.1.1.6 };'
    Old IP: 10.1.1.5 ... New IP: 10.1.1.6
    Old IP: 10.1.1.6 ... New IP: 10.1.1.5
    
  2. or download this
    johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -MSocket -E '
    my $IP     = q{10.1.1.255};
    ...
    printf qq{%8s %8s %8s %8s\n}, unpack q{(B8)*}, $packed;'
          10        1        1      255
    00001010 00000001 00000001 11111111
    
  3. or download this
    use strict;
    use warnings;
    ...
        my $newIP   = inet_ntoa( pack( q{N}, $numeric ) );
        printf qq{Old IP: %15s ... New IP: %15s\n}, $IP, $newIP;
    }
    
  4. or download this
    Old IP:        10.1.1.5 ... New IP:        10.1.1.6
    Old IP:        10.1.1.6 ... New IP:        10.1.1.5
    ...
    Old IP:         0.0.0.0 ... New IP: 255.255.255.255
    Old IP: 255.255.255.255 ... New IP:         0.0.0.0
    Old IP:    10.1.255.255 ... New IP:        10.2.0.0
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found