Thread Subnet Calculator
(10 answers)
Opened by Gast at 2007-10-12 10:48 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 #!/usr/bin/perl use strict; use warnings; my $start = '10.10.0.0'; my $stop = '10.10.0.0'; my $snm = '255.255.0.0'; my $cidr = '255.255.255.252'; my $end = '0.0.0.3'; my $group = 4; my $group_counter = 0; if( $start eq $stop ){ my @tmp = split /\./, $stop; for( reverse 0..3 ){ if( $tmp[$_] != 0 ){ $tmp[$_]++; last; } } $stop = join ".", @tmp; } my @first_ip = split /\./, $start; my @second_ip = split /\./, $stop; while(1){ last if join( ".", @first_ip ) eq $stop; $group_counter++; print sprintf "%s %s %s %s\n", join(".", @first_ip),$snm,$cidr,$end; $first_ip[-1]++; for( reverse 1..3 ){ if( $first_ip[$_] == 256 ){ $first_ip[$_-1] += 1; $first_ip[$_] = 0; } } if( $group_counter == 4 ){ print "-" x 40, "\n"; $group_counter = 0 ; } } OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |