Server IP : 49.212.180.16 / Your IP : 3.19.55.254 Web Server : Apache System : FreeBSD www2606.sakura.ne.jp 13.0-RELEASE-p14 FreeBSD 13.0-RELEASE-p14 #2: Mon Dec 9 13:54:55 JST 2024 root@www5301.sakura.ne.jp:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 User : utannto ( 1076) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/rs/perl/5.10/bin/ |
Upload File : |
#!/usr/local/perl/5.10/bin/perl use Net::IP; use strict; print "+----------------------------------------------+ | addrs bits pref class mask | +----------------------------------------------+ "; my ($ip,$size,$class,$bits,$len); my $ip = new Net::IP('0'); for my $len (reverse (0..32)) { $ip->set("0.0.0.0/$len"); $size = $ip->size(); if ($size >=1048576) # 1024*1024 { $size /= 1048576; $size .= 'M'; } elsif ($size >= 1024) { $size /= 1024; $size .= 'K'; }; $len = $ip->prefixlen(); $bits = 32 - $len; if ($bits >= 24) { $class = 2**($bits-24); $class.= 'A'; } elsif ($bits >= 16) { $class = 2**($bits-16); $class.= 'B'; } elsif ($bits >= 8) { $class = 2**($bits-8); $class.= 'C'; } printf ("| %5s %6s %6s %7s %-15s |\n", $size,$bits,'/'.$len,$class,$ip->mask()); }; print "+----------------------------------------------+\n";