Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: perl ipcalc oneliners

by monarch (Priest)
on Jun 09, 2005 at 23:55 UTC ( [id://465359]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # convert IP addresses to unsigned long integers
    my $addr="192.168.10.2";
    ...
    
    # print
    print( $netw );
    
  2. or download this
    # calculate broadcast address
    my $brodval = ( $addrval & $maskval ) + ( ~ $maskval );
    
  3. or download this
    # convert IP addresses to unsigned long integers
    my $addr="192.168.10.2";
    ...
    # print
    print( "Network:$netw\n" );
    print( "Broadcast:$brod\n" );
    
  4. or download this
    Network:192.168.10.0
    Broadcast:192.168.11.255
    
  5. or download this
    sub addrtoint { return( unpack( "N", pack( "C4", split( /[.]/,$_[0] ) 
    +) ) ) };
    sub inttoaddr { return( join( ".", unpack( "C4", pack( "N", $_[0] ) ) 
    +) ) };
    ...
    
    print( inttoaddr( $netwval ) . "\n" );
    print( inttoaddr( $brodval ) . "\n" );
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-06-22 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.