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

perl ipcalc oneliners

by mojobo (Initiate)
on Jun 09, 2005 at 23:21 UTC ( [id://465353]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -e '$ip="192.168.10.2"; $mask="255.255.254.0"; @maskbyte=split /\
    +./,$mask; @ipbyte=split /\./, $ip; for($i=0;$i<4;$i++) { $b1=$maskbyt
    +e[$i]+0; $b2=$ipbyte[$i]+0;$NetByte=$b1&$b2; if($i != 0) {$NetAddr = 
    +$NetAddr . "." . $NetByte; } else { $NetAddr=$NetByte ;}} print "$Net
    +Addr\n";'
    
  2. or download this
    perl -e '$ip="192.168.10.0"; $mask="255.255.254.0"; @maskbyte=split /\
    +./,$mask; @ipbyte=split /\./, $ip; for($i=0;$i<4;$i++) { $b1=$maskbyt
    +e[$i]+0; $b2=$ipbyte[$i]+0;  $NetByte=$b2 || ~$b1 ;  if($i != 0) {$Ne
    +tAddr = $NetAddr . "." . $NetByte; }else { $NetAddr=$NetByte ;}} prin
    +t "$NetAddr\n";'
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-06-21 20:44 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.