Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to include a variable in output for derived subnets

by poj (Monsignor)
on Jun 22, 2013 at 17:16 UTC ( #1040280=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use Socket;
    ...
      my $subnet_ip = Socket::inet_ntoa pack "N", $subnet_ipn; 
      printf "%-20s %s %x %s\n","$ip/$len",$ipn,$maskn,$subnet_ip;
    }
    
  2. or download this
    IP                   IPN        Mask      Subnet
    192.168.1.1/30       3232235777 3fffffffc 192.168.1.0
    ...
    192.168.1.8/30       3232235784 3fffffffc 192.168.1.8
    192.168.1.9/30       3232235785 3fffffffc 192.168.1.8
    etc
    
  3. or download this
    $subnets{"$ip,$len"}{ipn}   = $ipn;
    $subnets{"$ip,$len"}{maskn} = $maskn;
    if ( $subnets{"$ip,$len"}{'comment'} eq '' ){
      $subnets{"$ip,$len"}{'comment'} = $comment;
    } 
    
  4. or download this
    $subnets{"$ip,$len"} = { ipn => $ipn, maskn => $maskn };
    
  5. or download this
    print "subnet,prefix,name\n";
    print "$_,$subnet{$_}{'comment'}\n"
       for sort { $subnets{$a}{ipn} <=> $subnets{$b}{ipn} };
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040280]
help
Chatterbox?
[usemodperl]: greetings
[usemodperl]: question
[usemodperl]: perldoc -v 'ARGV' works but perldoc -v "STDIN' does not, but they are both filehandles. is there a perldoc for STDIN?
[usemodperl]: (typo not withstanding :)
usemodperl thinks about loose coupling...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-06-19 19:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (114 votes). Check out past polls.

    Notices?