"Fossies" - the Fresh Open Source Software Archive

Member "whois/make_ip_del.pl" (27 Jul 2017, 555 Bytes) of package /linux/privat/whois_5.5.9.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "make_ip_del.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl
    2 
    3 use warnings;
    4 use strict;
    5 
    6 while (<>) {
    7     chomp;
    8     s/#.*$//;
    9     s/^\s+//; s/\s+$//;
   10     next if /^$/;
   11 
   12     die "format error: $_" if not /^([\d\.]+)\/(\d+)\s+([\w\.]+)$/;
   13     my $m = $2; my $s = $3;
   14 
   15     my ($i1, $i2, $i3, $i4) = split(/\./, $1);
   16     print '{ ' . (($i1 << 24) + ($i2 << 16) + ($i3 << 8) + $i4) . 'UL, '.
   17         ((~(0xffffffff >> $m)) & 0xffffffff) . 'UL, "';
   18     if ($s =~ /\./) {
   19         print $s;
   20     } elsif ($s eq 'UNKNOWN') {
   21         print "\\005";
   22     } elsif ($s eq 'UNALLOCATED') {
   23         print "\\006";
   24     } else {
   25         print "whois.$s.net";
   26     }
   27     print qq|" },\n|;
   28 }
   29