{"id":178,"date":"2016-04-26T13:18:28","date_gmt":"2016-04-26T04:18:28","guid":{"rendered":"http:\/\/blog.grandaria.com\/?p=178"},"modified":"2016-04-26T13:19:06","modified_gmt":"2016-04-26T04:19:06","slug":"perl%e3%81%a7%e3%83%93%e3%83%83%e3%83%88%e6%bc%94%e7%ae%97%e3%81%99%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e6%b3%a8%e6%84%8f","status":"publish","type":"post","link":"https:\/\/blog.grandaria.com\/?p=178","title":{"rendered":"Perl\u3067\u30d3\u30c3\u30c8\u6f14\u7b97\u3059\u308b\u3068\u304d\u306e\u6ce8\u610f"},"content":{"rendered":"<p>\u30cf\u30de\u308a\u304b\u3051\u305f\u306e\u3067\u30e1\u30e2\u3002<\/p>\n<p>\u7d50\u8ad6\u3001perl\u306e\u30d3\u30c3\u30c8\u6f14\u7b97\u6642\u306f\u3001\u6587\u5b57\u5217\u3068\u6570\u5024\u3092\u6c17\u3092\u3064\u3051\u306a\u3044\u3068\u884c\u3051\u306a\u3044\u3002<\/p>\n<p>\u4ed6\u306e\u6f14\u7b97\u5b50\u306f\u3001\u6587\u5b57\u5217\u7528\u3068\u6570\u5024\u7528\u306b\u5206\u304b\u308c\u3066\u308b\u3051\u3069\u3053\u308c\u3060\u3051\u5206\u304b\u308c\u3066\u3044\u306a\u3044\u3002<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u304c\u3042\u308b\u3002<\/p>\n<pre class=\"lang:perl decode:true\" title=\"getnetworkaddress.pl\">my $lan_IP = shift;\r\nmy $lan_Mask = shift;\r\n\r\n$lan_IP =~ \/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$\/;\r\nmy $a1 = $1; my $a2 = $2; my $a3 = $3; my $a4 = $4;\r\n$lan_Mask =~ \/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$\/;\r\nmy $b1 = $1; my $b2 = $2; my $b3 = $3; my $b4 = $4;\r\n\r\nprintf \"NA:%d.%d.%d.%d\\n\", $a1 &amp; $b1, $a2 &amp; $b2, $a3 &amp; $b3, $a4 &amp; $b4;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308b<\/p>\n<blockquote><p>$ perl .\/getnetworkaddress.pl 192.168.1.250 255.255.255.0<\/p>\n<p>NA:10.40.0.0<\/p><\/blockquote>\n<p>\u672c\u6765\u307b\u3057\u3044\u5024\u306f\u3001\u300cNA:192.168.1.0\u300d\u3067\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001printf\u306e\u524d\u306b\u4e0b\u8a181\u884c\u3092\u633f\u5165\u3059\u308b\u3068\u3001\u6b63\u3057\u304f\u3001192.168.1.0\u3068\u306a\u308b\u3002<\/p>\n<blockquote><p>printf &#8220;%d.%d.%d.%d\\n&#8221;, $a1, $a2, $a3, $a4;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\u57fa\u672c\u3001Perl\u306f\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u6570\u5024\u304b\u6587\u5b57\u5217\u304b\u81ea\u52d5\u3067\u8003\u3048\u3066\u304f\u308c\u308b\u3051\u3069\u3001<\/p>\n<p>\u4eca\u56de\u3053\u308c\u304c\u826f\u304f\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u4f8b\u3002<\/p>\n<p>JavaScript\u306e\u6642\u306b\u554f\u984c\u306b\u306a\u308b\u6570\u5024\u540c\u58eb\u306e\u8db3\u3057\u7b97\u304c\u3001\u6587\u5b57\u5217\u3068\u3057\u3066\u6271\u308f\u308c\u3066\u3057\u307e\u3046\u7b49\u306e\u554f\u984c\u306f\u3001<\/p>\n<p>\u6f14\u7b97\u5b50\u304c\u7570\u306a\u308b\uff08\u6587\u5b57\u5217\u300c.\u300d\u3001\u6570\u5024\u300c+\u300d\uff09\u3053\u3068\u306b\u3088\u3063\u3066\u554f\u984c\u7121\u3044\u304c\u3001<\/p>\n<p>\u30d3\u30c3\u30c8\u6f14\u7b97\u306f\u6f14\u7b97\u5b50\u304c\u4e00\u7dd2\u306a\u306e\u3067\u2026\u2026\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3061\u3087\u3063\u3068\u5c0f\u7d30\u5de5\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>2\u884c\u76ee\u3067\u3001\u305d\u308c\u305e\u308c\u6b63\u898f\u8868\u73fe\u304b\u3089\u3068\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u3067+0\u3092\u3057\u3066\u3084\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:perl decode:true \" title=\"getnetworkaddress2.pl\">my $lan_IP = shift;\r\nmy $lan_Mask = shift;\r\n\r\n$lan_IP =~ \/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$\/;\r\nmy $a1 = $1+0; my $a2 = $2+0; my $a3 = $3+0; my $a4 = $4+0;\r\n$lan_Mask =~ \/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$\/;\r\nmy $b1 = $1+0; my $b2 = $2+0; my $b3 = $3+0; my $b4 = $4+0;\r\n\r\nprintf \"NA:%d.%d.%d.%d\\n\", $a1 &amp; $b1, $a2 &amp; $b2, $a3 &amp; $b3, $a4 &amp; $b4;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u3053\u3046\u3057\u3066\u3042\u3052\u308b\u3053\u3068\u3067\u3001\u6b63\u3057\u3044\u5024\u304c\u51fa\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3061\u306a\u307f\u306b\u6587\u5b57\u5217\u3092\u660e\u793a\u3057\u305f\u3044\u5834\u5408\u306f\u3001<\/p>\n<p>\u300c.&#8221;&#8221;\u300d\uff08\u300c.&#8221;\u300d\u3067\u3082OK\uff09\u3092\u3064\u3051\u3066\u4e0a\u3052\u308b\u3053\u3068\u3067\u53ef\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30cf\u30de\u308a\u304b\u3051\u305f\u306e\u3067\u30e1\u30e2\u3002 \u7d50\u8ad6\u3001perl\u306e\u30d3\u30c3\u30c8\u6f14\u7b97\u6642\u306f\u3001\u6587\u5b57\u5217\u3068\u6570\u5024\u3092\u6c17\u3092\u3064\u3051\u306a\u3044\u3068\u884c\u3051\u306a\u3044\u3002 \u4ed6\u306e\u6f14\u7b97\u5b50\u306f\u3001\u6587\u5b57\u5217\u7528\u3068\u6570\u5024\u7528\u306b\u5206\u304b\u308c\u3066\u308b\u3051\u3069\u3053\u308c\u3060\u3051\u5206\u304b\u308c\u3066\u3044\u306a\u3044\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/posts\/178"}],"collection":[{"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":2,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.grandaria.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}