{"id":1767,"date":"2019-07-01T21:00:53","date_gmt":"2019-07-01T12:00:53","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=1767"},"modified":"2025-11-19T09:52:03","modified_gmt":"2025-11-19T00:52:03","slug":"perl-if","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/perl-if","title":{"rendered":"Perl\u306eif\u6587\u3068\u306f\uff1fif\u6587\u3092\u4f7f\u3063\u305f\u6761\u4ef6\u5224\u65ad\uff5e\u6bd4\u8f03\u6f14\u7b97\u5b50\u3084\u6b63\u898f\u8868\u73fe\u306e\u6d3b\u7528\uff5e"},"content":{"rendered":"<p>Perl\u306b\u3082\u4ed6\u306e\u8a00\u8a9e\u3068\u540c\u69d8<span>if<\/span>\u6587\u304c\u3042\u308a\u307e\u3059\u3002\u3057\u304b\u3057<span>Perl<\/span>\u306a\u3089\u3067\u306f\u306e\u4f7f\u3044\u65b9\u3084\u3001\u6709\u540d\u306a\u8a00\u8a9e\u3068\u5c11\u3057\u7570\u306a\u308b\u70b9\u3082\u3042\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002\u899a\u3048\u3066\u3057\u307e\u3048\u3070\u4ed6\u306e\u8a00\u8a9e\u306b\u6bd4\u3079\u3068\u3066\u3082\u4f7f\u3044\u3084\u3059\u304f\u611f\u3058\u308b\u3068\u601d\u3044\u307e\u3059\uff01\u5b9f\u969b\u306b\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u7406\u89e3\u3092\u6df1\u3081\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Perlif\">\uff11\uff0e\u3010Perl\u3011if\u6587\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a><\/li><li><a href=\"#Perlelse_elsif\">\uff12\uff0e\u3010Perl\u3011\u8907\u6570\u306e\u6761\u4ef6\u5206\u5c90(else, elsif)<\/a><\/li><li><a href=\"#Perlif-2\">\uff13\uff0e\u3010Perl\u3011if\u6587\u3067\u4f7f\u7528\u3059\u308b\u6f14\u7b97\u5b50<\/a><ul><li><a href=\"#i\">\uff13-\uff11\uff0e\u8ad6\u7406\u6f14\u7b97\u5b50<\/a><\/li><li><a href=\"#i-2\">\uff13-\uff12\uff0e\u6570\u5024\u6bd4\u8f03\u6f14\u7b97\u5b50<\/a><\/li><li><a href=\"#i-3\">\uff13-\uff13\uff0e\u6587\u5b57\u5217\u6bd4\u8f03\u6f14\u7b97\u5b50<\/a><\/li><\/ul><\/li><li><a href=\"#Perlif-3\">\uff14\uff0e\u3010Perl\u3011\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305fif\u6587<\/a><\/li><li><a href=\"#i-4\">\uff15\uff0e\u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Perlif\">\uff11\uff0e\u3010Perl\u3011if\u6587\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/span><\/h2>\n<p>\u300c\u3082\u3057\u3007\u3007\u3067\u3042\u308b\u5834\u5408\u3001\u25b3\u25b3\u306e\u51e6\u7406\u3092\u3059\u308b\u300d\u3068\u3044\u3063\u305f\u3088\u3046\u306b\u3042\u308b\u6761\u4ef6\u306e\u6642\u3060\u3051\u7279\u5b9a\u306e\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u66f8\u304d\u65b9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>if ( \u6761\u4ef6\u5f0f <span>) {<\/span><\/p>\n<p>\u00a0\u00a0\u00a0 \u6761\u4ef6\u5f0f\u3092\u6e80\u305f\u3059\uff08\u771f\uff09\u306e\u6642\u306e\u51e6\u7406<\/p>\n<p>}<\/p>\n<\/blockquote>\n<pre class=\"prettyprint lang:default decode:true\">my $a = 10;\r\nmy $b = 2;\r\nif ($a % $b == 0) {\r\n    print \"$a\u306f$b\u3067\u5272\u308a\u5207\u308c\u307e\u3059\u3002\\n\";\r\n}\r\nprint \"\u304a\u308f\u308a\";\r\n\u5b9f\u884c\u7d50\u679c\uff1a\r\n10\u306f2\u3067\u5272\u308a\u5207\u308c\u307e\u3059\u3002\r\n\u304a\u308f\u308a<\/pre>\n<p>$b=2\u3092<span>$b=3<\/span>\u306b\u5909\u66f4\u3059\u308b\u3068\u3001\u300c\u304a\u308f\u308a\u300d\u3057\u304b\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002\u5b9f\u969b\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u78ba\u304b\u3081\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>Perl\u306f<span>if<\/span>\u4fee\u98fe\u5b50\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\uff11\u884c\u3067\u66f8\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\u6761\u4ef6\u5f0f\u3092\u6e80\u305f\u3059\uff08\u771f\uff09\u306e\u6642\u306e\u51e6\u7406 <span>if (<\/span>\u6761\u4ef6\u5f0f);<\/p>\n<\/blockquote>\n<pre class=\"prettyprint lang:default decode:true\">for (my $num = 0; $num &lt; 10; $num++) {\r\n    print \"$num \\n\" if ($num == 5);\r\n}\r\n\u5b9f\u884c\u7d50\u679c\uff1a\r\n5<\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3059\u308b\u524d\u306b\u3001\u305d\u308c\u304c\u3069\u306e\u3088\u3046\u306a\u72b6\u614b\u306b\u3042\u308b\u306e\u304b\u691c\u67fb\u3057\u305f\u3044\u3068\u304d\u306f\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">if (-e \"sample.txt\") {    # sample.txt\u304c\u5b58\u5728\u3059\u308c\u3070\u771f\r\n    print \"sample.txt\u5b58\u5728\u3057\u307e\u3059\u3002\\n\";\r\n}\r\nelse {\r\n    print \"sample.txt\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\\n\";\r\n}\r\n\u5b9f\u884c\u7d50\u679c\uff1a\r\nsample.txt\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002<\/pre>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u5b58\u5728\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3053\u3046\u3068\u3057\u3066\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u2026\u3068\u3044\u3046\u3053\u3068\u3092\u907f\u3051\u3089\u308c\u307e\u3059\u306d\u3002\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3088\u304f\u4f7f\u7528\u3059\u308b\u3082\u306e\u306e\u307f\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306e<span>\u201d-e\u201d<\/span>\u306e\u90e8\u5206\u3092\u66f8\u304d\u63db\u3048\u3066\u3001\u8272\u3005\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-r<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u8aad\u307f\u8fbc\u307f\u53ef\u80fd\u3067\u3042\u308c\u3070\u771f<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-w<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u66f8\u304d\u8fbc\u307f\u53ef\u80fd\u3067\u3042\u308c\u3070\u771f<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-e<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u5b58\u5728\u3059\u308c\u3070\u771f<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-z<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u30b5\u30a4\u30ba\u304c<span>0<\/span>\u3067\u3042\u308c\u3070\u771f<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-f<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308c\u3070\u771f<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; border-color: #000000;\">-T<\/td>\n<td style=\"width: 50%; border-color: #000000;\">\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308c\u3070\u771f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span id=\"Perlelse_elsif\">\uff12\uff0e\u3010Perl\u3011\u8907\u6570\u306e\u6761\u4ef6\u5206\u5c90(else, elsif)<\/span><\/h2>\n<p>\u3082\u3057<span>A<\/span>\u306e\u5834\u5408\u306f<span>AA<\/span>\u306e\u51e6\u7406\u3001<span>B<\/span>\u306e\u5834\u5408\u306f<span>BB<\/span>\u306e\u51e6\u7406\u3001<span>C<\/span>\u306e\u5834\u5408\u306f\u30fb\u30fb\u30fb\u3068\u3044\u3046\u3088\u3046\u306b\u8907\u6570\u306e\u6761\u4ef6\u3067\u51e6\u7406\u3092\u5206\u3051\u305f\u3044\u3068\u304d\u306f\u6b21\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">my @list = ('B', 'C', 'A', 'D');\r\nmy $num = 0;\r\nforeach (@list) {\r\n    $num++;\r\n    if ($_ eq 'A') {\r\n        print \"$num\u756a\u76ee\u306bA\\n\";\r\n    }\r\n    elsif ($_ eq 'B') {     # elsif\u306f\u3044\u304f\u3064\u7e4b\u3052\u3066\u3082OK\r\n        print \"$num\u756a\u76ee\u306bB\\n\";\r\n    }\r\n    else {\r\n        print \"A\u3067\u3082B\u3067\u3082\u306a\u3044($_)\\n\";\r\n    }\r\n}\r\n\u5b9f\u884c\u7d50\u679c\uff1a\r\n1\u756a\u76ee\u306bB\r\nA\u3067\u3082B\u3067\u3082\u306a\u3044(C)\r\n3\u756a\u76ee\u306bA\r\nA\u3067\u3082B\u3067\u3082\u306a\u3044(D)<\/pre>\n<p>Java\u3084<span>C<\/span>\u8a00\u8a9e\u306e\u5834\u5408\u306f\u300c<span>else if<\/span>\u300d\u3067\u3059\u304c\u3001<span>Perl<\/span>\u306f\u300c<span>elsif<\/span>\u300d\u306a\u306e\u3067\u6c17\u3092\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u6761\u4ef6\u5f0f\u306b\u3042\u308b<span>\u201deq\u201d<\/span>\u306f\u3001\u6570\u5b57\u3067\u306f\u306a\u304f\u6587\u5b57\u3092\u6bd4\u8f03\u3059\u308b\u5834\u5408\u306e\u6f14\u7b97\u5b50\u3067\u3059\u3002<span>3-2<\/span>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2><span id=\"Perlif-2\">\uff13\uff0e\u3010Perl\u3011if\u6587\u3067\u4f7f\u7528\u3059\u308b\u6f14\u7b97\u5b50<\/span><\/h2>\n<p>if\u6587\u3067\u306f\u3088\u304f\u6bd4\u8f03\u306b\u300c<span>==<\/span>\u300d\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<p>\u3053\u308c\u306f<span>Perl<\/span>\u3067\u306f\u6570\u5024\u3092\u6bd4\u8f03\u3059\u308b\u3068\u304d\u306b\u4f7f\u7528\u3059\u308b\u6f14\u7b97\u5b50\u3067\u3059\u3002\u6bd4\u8f03\u5bfe\u8c61\u304c\u6570\u5024\u306a\u306e\u304b\u3001\u6587\u5b57\u5217\u306a\u306e\u304b\u3067\u4f7f\u7528\u3059\u308b\u6f14\u7b97\u5b50\u304c\u5909\u308f\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"i\">\uff13-\uff11\uff0e\u8ad6\u7406\u6f14\u7b97\u5b50<\/span><\/h3>\n<p>\u8907\u6570\u306e\u6761\u4ef6\u5f0f\u3092<span>if<\/span>\u6587\u306e\u4e2d\u3067\u7d44\u307f\u5408\u308f\u305b\u305f\u3044\u5834\u5408\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u6f14\u7b97\u5b50<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u610f\u5473<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u4f7f\u7528\u4f8b<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">&amp;&amp; \/ and<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u8ad6\u7406\u7a4d\uff08\u304b\u3064\uff09<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &gt; 0 &amp;&amp; $b &lt; 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">||\u00a0 \/ or<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u8ad6\u7406\u548c\uff08\u307e\u305f\u306f\uff09<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &gt; 0 || $b &lt; 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">xor<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u6392\u4ed6\u7684\u8ad6\u7406\u548c<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &gt; 0 xor $b &lt; 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">!\u00a0\u00a0 \/ not<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u5426\u5b9a<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if (!$a==0)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&amp;&amp; \u3068 <span>and<\/span>\u306f\u512a\u5148\u9806\u4f4d\u304c\u7570\u306a\u308a\u307e\u3059\u3002<span>and<\/span>\u3084<span>or<\/span>\u306f\u3001<span>&amp;&amp;<\/span>\u3084<span>||<\/span>\u3088\u308a\u3082\u512a\u5148\u9806\u4f4d\u304c\u4f4e\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"i-2\">\uff13-\uff12\uff0e\u6570\u5024\u6bd4\u8f03\u6f14\u7b97\u5b50<\/span><\/h3>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u6f14\u7b97\u5b50<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u610f\u5473<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">\u4f7f\u7528\u4f8b<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A == B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u3044<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a == 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A != B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u304f\u306a\u3044<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a != 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A &gt; B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u304c<span>B<\/span>\u3088\u308a\u5927\u304d\u3044<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &gt; 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A &gt;= B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u304c<span>B<\/span>\u4ee5\u4e0a<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &gt;= 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A &lt; B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u304c<span>B<\/span>\u3088\u308a\u5c0f\u3055\u3044<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &lt; 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A&lt;= B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u304c<span>B<\/span>\u4ee5\u4e0b<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &lt;= 0)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%; border-color: #000000;\">A &lt;==&gt; B<\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u3051\u308c\u3070<span>0<br \/>\nA\u3088\u308aB\u304c\u5c0f\u3055\u3051\u308c\u3070-1<br \/>\nA\u3088\u308aB\u304c\u5927\u304d\u3051\u308c\u30701<\/span><\/td>\n<td style=\"width: 33.3333%; border-color: #000000;\">if ($a &lt;==&gt; 0)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u300c<span>&gt;=<\/span>\u300d\u3092\u300c<span>=&gt;<\/span>\u300d\u306e\u3088\u3046\u306b\u9593\u9055\u308f\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3><span id=\"i-3\">\uff13-\uff13\uff0e\u6587\u5b57\u5217\u6bd4\u8f03\u6f14\u7b97\u5b50<\/span><\/h3>\n<p>\u4e0a\u306e\u8868\u3068\u898b\u6bd4\u3079\u3066\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u3061\u3089\u306f\u4f55\u306e\u7565\u304b\u3092\u8003\u3048\u308b\u3068\u899a\u3048\u3084\u3059\u3044\u3067\u3059\u306d\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">\u6f14\u7b97\u5b50<\/td>\n<td style=\"width: 45.727%; height: 24px;\">\u610f\u5473<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">\u4f7f\u7528\u4f8b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A eq B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u3044 <span>(<\/span><span style=\"color: #ff0000;\">eq<\/span>ual)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a eq \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A ne B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u304f\u306a\u3044 <span>(<\/span><span style=\"color: #ff0000;\">n<\/span>ot <span style=\"color: #ff0000;\">e<\/span>qual)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a ne \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A gt B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u304c<span>B<\/span>\u3088\u308a\u5927\u304d\u3044<span> (<\/span><span style=\"color: #ff0000;\">g<\/span>reater<span style=\"color: #ff0000;\"> t<\/span>han)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a gt \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A ge B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u304c<span>B<\/span>\u4ee5\u4e0a <span>(<\/span><span style=\"color: #ff0000;\">g<\/span>reater than <span style=\"color: #ff0000;\">e<\/span>qual to)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a ge \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A lt B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u304c<span>B<\/span>\u3088\u308a\u5c0f\u3055\u3044 <span>(<\/span><span style=\"color: #ff0000;\">l<\/span>ess <span style=\"color: #ff0000;\">t<\/span>han)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a lt \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A le B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u304c<span>B<\/span>\u4ee5\u4e0b <span>(<\/span><span style=\"color: #ff0000;\">l<\/span>ess than<span style=\"color: #ff0000;\"> e<\/span>qual to)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a le \u2018A\u2019)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 20.9396%; height: 24px;\">A cmp B<\/td>\n<td style=\"width: 45.727%; height: 24px;\">A\u3068<span>B<\/span>\u304c\u7b49\u3057\u3051\u308c\u3070<span>0<br \/>\nA\u3088\u308aB\u304c\u5c0f\u3055\u3051\u308c\u3070-1<br \/>\nA\u3088\u308aB\u304c\u5927\u304d\u3051\u308c\u30701<\/span><br \/>\n(<span style=\"color: #ff0000;\">c<\/span>o<span style=\"color: #ff0000;\">mp<\/span>are)<\/td>\n<td style=\"width: 33.3333%; height: 24px;\">if ($a cmp \u2018A\u2019)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u2018<span>A<\/span>\u2019\u306e\u90e8\u5206\u306f\u76f4\u63a5\u6587\u5b57\u5217\u3092\u3044\u308c\u306a\u304f\u3066\u3082\u3001\u6587\u5b57\u3092\u4ee3\u5165\u3057\u305f\u5909\u6570\u3067\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<\/p>\n<h2><span id=\"Perlif-3\">\uff14\uff0e\u3010Perl\u3011\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305fif\u6587<\/span><\/h2>\n<p>\u5b8c\u5168\u4e00\u81f4\u3067\u306f\u306a\u304f\u3001\u6587\u5b57\u5217\u306e\u4e2d\u306b\u30d1\u30bf\u30fc\u30f3\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u8abf\u3079\u305f\u3044\u5834\u5408\u306b\u306f\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">my $str = 'red blue yellow green white';\r\nif ($str =~ \/wh\/) {\r\n    print \"wh\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\\n\";\r\n}\r\nelse {\r\n    print \"wh\u306f\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002\\n\";\r\n}\r\n\u5b9f\u884c\u7d50\u679c\uff1a\r\nwh\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/pre>\n<p>If\u6587\u306e\u6761\u4ef6\u5f0f\u306b\u3042\u308b\u300c<span>=~<\/span>\u300d\u306f\u3001\u30d1\u30bf\u30fc\u30f3\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u771f\u3068\u306a\u308a\u307e\u3059\u3002\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3068\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u300c<span>!~<\/span>\u300d\u3068\u3057\u307e\u3059\u3002\u6b63\u898f\u8868\u73fe\u306b\u3064\u3044\u3066\u306f\u4e0b\u8a18\u8a18\u4e8b\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<span style=\"text-decoration:none !important; background-color:#a61e58; color:white; padding:4px 13px; font-size:12px; font-weight:bold; position:relative; top:10px; z-index:1; left:11px;\">\u95a2\u9023\u8a18\u4e8b<\/span>\n<div class=\"blog-card\"><a target=\"_blank\" href=\"https:\/\/www.bold.ne.jp\/engineer-club\/perl-regular-expression\" style=\"text-decoration:none;\">\n    <div class=\"blog-card-thumbnail\"><img src='https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2018\/12\/shutterstock_371211334-600x366.jpg' alt='Perl\u306e\u6b63\u898f\u8868\u73fe\uff5c\u6587\u5b57\u5217\u306e\u691c\u7d22\u30fb\u7f6e\u63db\u306a\u3069\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9' width=160 height=98 \/><\/div>\n    <div class=\"blog-card-content\">\n        <div class=\"blog-card-title\">Perl\u306e\u6b63\u898f\u8868\u73fe\uff5c\u6587\u5b57\u5217\u306e\u691c\u7d22\u30fb\u7f6e\u63db\u306a\u3069\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9 <\/div>\n        <span style=\"font-size: 12px; font-weight: normal; position:relative; color:#666;\"><i class=\"fa fa-clock-o\"><\/i>&nbsp;2025\/09\/17<\/span>\n    <\/div>\n<div class=\"clear\"><\/div>\n<\/a><\/div>\n<h2><span id=\"i-4\">\uff15\uff0e\u307e\u3068\u3081<\/span><\/h2>\n<p>Perl\u306e<span>if<\/span>\u6587\u3067\u6c17\u3092\u4ed8\u3051\u308b\u3068\u3053\u308d\u306f\u3001<span>\u201delsif\u201d<\/span>\u306e\u7db4\u308a\u3068\u3001\u6570\u5024\u3068\u6587\u5b57\u5217\u306e\u6bd4\u8f03\u6f14\u7b97\u5b50\u304c\u7570\u306a\u308b\u3068\u3053\u308d\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306f\u4ed6\u306e\u8a00\u8a9e\u3068\u307b\u307c\u540c\u3058\u306a\u306e\u3067\u3001\u5b9f\u969b\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308c\u3070\u3059\u3050\u899a\u3048\u3089\u308c\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Perl\u306b\u3082\u4ed6\u306e\u8a00\u8a9e\u3068\u540c\u69d8if\u6587\u304c\u3042\u308a\u307e\u3059\u3002\u3057\u304b\u3057Perl\u306a\u3089\u3067\u306f\u306e\u4f7f\u3044\u65b9\u3084\u3001\u6709\u540d\u306a\u8a00\u8a9e\u3068\u5c11\u3057\u7570\u306a\u308b\u70b9\u3082\u3042\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002\u899a\u3048\u3066\u3057\u307e\u3048\u3070\u4ed6\u306e\u8a00\u8a9e\u306b\u6bd4\u3079\u3068\u3066\u3082\u4f7f\u3044\u3084\u3059\u304f\u611f\u3058\u308b\u3068\u601d\u3044\u307e\u3059\uff01\u5b9f\u969b\u306b\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u7406\u89e3 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":1168,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1767"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=1767"}],"version-history":[{"count":9,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1767\/revisions"}],"predecessor-version":[{"id":1770,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1767\/revisions\/1770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/1168"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=1767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=1767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}