{"id":1378,"date":"2008-08-17T13:00:00","date_gmt":"2008-08-17T04:00:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=95"},"modified":"2008-08-17T13:00:00","modified_gmt":"2008-08-17T04:00:00","slug":"blogn-95","status":"publish","type":"post","link":"https:\/\/hdmr.org\/d\/?e=95","title":{"rendered":"open or die\u3068\u3044\u3046\u306e\u306f\u8105\u8feb\u3067\u306f\u306a\u3044\u3088\u3068\u8a00\u3044\u305f\u3044"},"content":{"rendered":"<p>\u6628\u65e5\u3061\u3087\u3063\u3068or die\u306e\u8a71\u3092\u53d6\u308a\u4e0a\u3052\u305f\u3051\u3069\u3001\u3042\u308c\u306f\u7d50\u69cb\u5909\u306a\u4ed5\u639b\u3051\u3089\u3057\u3044\u3002<\/p>\n<pre>open IF,'<test' or die;<\/pre>\n<p>\u666e\u6bb5\u306f3\u5909\u6570open\u3092\u4f7f\u3046\u3051\u3069\u7701\u30b9\u30da\u30fc\u30b9\u306e\u305f\u30812\u5909\u6570open\u3060\u3088\u3002<br \/>\u3055\u3066\u3001\u3069\u3093\u306a\u5177\u5408\u304b\u3001\u305d\u308c\u3063\u307d\u3044\u30d5\u30ed\u30fc\u30c1\u30e3\u30fc\u30c8\u3067\u66f8\u3044\u3066\u307f\u3088\u3046\u3002<br \/><img loading=\"lazy\" decoding=\"async\" src=\".\/img\/flow0.png\" width=\"320\" height=\"180\" alt=\"or die\u306e\u30a4\u30e1\u30fc\u30b8\u56f3\" ><br \/>\u5de6\u304c\u5b9f\u969b\u306e\u52d5\u4f5c\u3002RES\u306f\u8fd4\u308a\u5024\u304c\u5165\u308b\u4eee\u5909\u6570\u3002\u3069\u3046\u3067\u3082\u3044\u3044\u3051\u3069\u3002<br \/>1\u3068\u4f55\u306eor\u3092\u53d6\u3063\u3066\u30821\u306b\u306a\u308b\u3068\u3044\u3046\u6027\u8cea\u3092\u4f7f\u3063\u3066\u308b\u308f\u3051\u3060\u3002<br \/>\u8fd4\u308a\u5024\u3068\u3057\u30661\u3092\u53d7\u3051\u53d6\u3063\u305f\u6642\u70b9\u3067\u30011\u3068\u3044\u3046\u7d50\u8ad6\u3092\u51fa\u3057\u3066\u3057\u307e\u3046\u3002<br \/>\u3060\u304b\u3089open\u306e\u6642\u70b9\u30671\u3068\u306a\u308c\u3070\u3001die\u306e\u7d50\u679c\u304c0\u3060\u308d\u3046\u304c\u3001\u6700\u7d42\u7684\u306a\u7b54\u3048\u306f1\u3060\u304b\u3089die\u306f\u5b9f\u884c\u3057\u306a\u304f\u3066\u3044\u3044\u3068\u3002<br \/>\u3053\u3046\u3044\u3046\u6027\u8cea\u3092\u6301\u3064\u3001|| , && , or , and \u306e\u6f14\u7b97\u5b50\u3092\u77ed\u7d61\u8ad6\u7406\u6f14\u7b97\u5b50\u3068\u304b\u3044\u3046\u3089\u3057\u3044\u3002<br \/>\u3069\u306e\u8fba\u304c\u77ed\u7d61\u306a\u306e\u304b\u3068\u3044\u3046\u3068\u3001die\u306e\u7d50\u679c\u3092\u78ba\u8a8d\u305b\u305a\u306b\u7d50\u8ad6\u3092\u51fa\u3059\u3042\u305f\u308a\u3002<br \/>\u975e\u5e38\u306b\u5909\u306a\u8a71\u3067\u3059\u3002or die\u3092\u4f7f\u3063\u3066\u308b\u4eba\u306f\u53f3\u306e\u30d5\u30ed\u30fc\u30c1\u30e3\u30fc\u30c8\u306e\u3088\u3046\u306b\u3057\u304b\u8003\u3048\u3066\u3044\u306a\u3044\u3002<br \/>\u3057\u304b\u3057\u306a\u304c\u3089\u3053\u308c\u306f\u3001<\/p>\n<pre>unless(open IF,'<test'){die;}<br \/>die unless(open IF,'<test');<\/pre>\n<p>unless\u306fif\u306e\u9006\u3002\u507d\u306a\u3089\u3070\u5b9f\u884c\u3002\u3060\u304b\u3089if(!open IF,'<test')\u3067\u3082\u3044\u3044\u3093\u3060\u3051\u3069\u306d\u3002<br \/>\u307e\u3041\u3069\u308c\u306b\u3057\u3066\u3082\u3061\u3087\u3063\u3068\u3082\u3063\u3055\u308a\u3057\u3066\u308b\u304b\u3089or die\u306f\u4fbf\u5229\u3067\u3059\u306d\u3002<br \/>Perl\u3068\u304b\u3001PHP\u3067\u3082\u4f7f\u3046\u307f\u305f\u3044\u3060\u3051\u3069\u3001C\u3067\u4f7f\u3063\u3066\u308b\u306e\u306f\u898b\u305f\u3053\u3068\u304c\u306a\u3044\u3002\u3060\u304c\u3001C\u3067\u3082\u4f7f\u3048\u308b\u307f\u305f\u3044\u3002<\/p>\n<hr \/>\n<p>or\u3067\u3067\u304d\u308b\u306e\u306a\u3089and\u3067\u3082\u3067\u304d\u307e\u3059\u3088\u3002<\/p>\n<pre>@arr and print @arr;<\/pre>\n<p>\u306a\u3093\u304b\u6c17\u6301\u3061\u60aa\u3044\u3051\u3069\u306d\u3002\u3051\u3069\u7406\u5c48\u306f\u4e00\u7dd2\u3060\u3002<br \/><img loading=\"lazy\" decoding=\"async\" src=\".\/img\/flow1.png\" width=\"300\" height=\"140\" alt=\"and print\u306e\u30a4\u30e1\u30fc\u30b8\" ><br \/>if(@arr)\u3068\u3044\u3046\u306e\u306f\u3001@res\u306b\u8981\u7d20\u304c\u3042\u308b\u304b\u306a\u3044\u304b\u3060\u3002\u3068\u3044\u3046\u308f\u3051\u3067\u3055\u3063\u304d\u306e\u306f\u666e\u901a\u306f\u3001<\/p>\n<pre>print @arr if(@arr);<\/pre>\n<p>\u3068\u66f8\u304d\u307e\u3059\u306d\u3002\u307e\u3041\u3053\u308c\u3092and\u3067\u66f8\u3051\u3070\u30b9\u30de\u30fc\u30c8\u306b\u66f8\u3051\u308b\u304b\u3082\u3068\u8a00\u3063\u305f\u304c\u6c17\u6301\u3061\u60aa\u3044\u3060\u3051\u3060\u3002<br \/>\u4ee5\u4e0a\u306e\u3053\u3068\u304b\u3089\u3053\u3046\u3044\u3046\u516c\u5f0f\u304c\u51fa\u6765\u307e\u3059\u306d\u3002<\/p>\n<pre>func1() or func2(); \u21d4 func2() unless(func1()); \u21d4 unless(func1()){func2();}<br \/>func1() and func2(); \u21d4 func2() if(func1()); \u21d4 if(func1()){func2();}<\/pre>\n<p>\u3069\u3046\u3067\u3082\u3044\u3044\u3051\u3069\u3001unless\u3063\u3066\u672c\u5f53\u306b\u4f7f\u308f\u306a\u3044\u3088\u306d\u30fc\u3002\u307e\u3041!\u3067\u5426\u5b9a\u3059\u308a\u3083\u3044\u3044\u3060\u3051\u3060\u304b\u3089\u306d\u3002<br \/>\u4f59\u8ac7\u3060\u304c\u3001\u50d5\u306f\u3053\u3093\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u3088\u304f\u66f8\u304f\u3002<\/p>\n<pre>my @matches=($data =~ m\/^([0-9]+)\\s+(.+)$\/mg );<br \/>my @person=();<br \/>while(@matches){<br \/>  push(@person, {id=>shift(@matches) , name=>shift(@matches) } );<br \/>}<\/pre>\n<p>\u8907\u6570\u30de\u30c3\u30c1\u3068\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u3001('001','Taro Yamada','002','Ken Kimura')\u306e\u3088\u3046\u306a\u30ea\u30b9\u30c8\u304c\u3067\u304d\u308b\u304b\u3089\u3001<br \/>\u3053\u308c\u3092\u524d\u304b\u3089shift\u30672\u500b\u5f15\u304d\u629c\u3044\u3066\u3001\u30cf\u30c3\u30b7\u30e5\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u65b0\u3057\u3044\u30ea\u30b9\u30c8\u306bpush\u3057\u3066\u3001\u3068\u3044\u3046\u306e\u3092@matches\u304c\u5168\u90e8\u306a\u304f\u306a\u308b\u307e\u3067\u3084\u308b\u3068\u3002<br \/>\u3053\u308c\u306f\u306a\u304b\u306a\u304b\u4fbf\u5229\u3067\u3059\u3088\u3002<\/p>\n<hr \/>\n<p>or\u3068and\u3001\u3046\u30fc\u3093\u2026\u3069\u3093\u306a\u3068\u304d\u4f7f\u3048\u308b\u304b\u306a\u3041\u2026<\/p>\n<pre>open IF,'<','test.txt'; <br \/>my @data=();<br \/>while(<if>){<br \/>  m\/^([0-9]+)\\s+(.+)$\/ or next;<br \/>  push(@data,{id=>$1,name=>$2});<br \/>}<\/pre>\n<p>or\u306f\u3053\u3093\u306a\u98a8\u306a\u4f7f\u3044\u9053\u304c\u3042\u308a\u307e\u3059\u304b\u306a\u3002<br \/>or\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u304b\u5f37\u5236\u7d42\u4e86\u304b\u3001\u30de\u30c3\u30c1\u3059\u308b\u304b\u4e00\u5468\u7d42\u308f\u308a\u304b\u3001\u307f\u305f\u3044\u306b\u610f\u5473\u3082\u3064\u304b\u307f\u3084\u3059\u3044\u3067\u3059\u306d\u3002<br \/>\u5b9f\u969b\u306e\u610f\u5473\u306f\u305d\u3093\u306a\u3053\u3068\u3067\u306f\u306a\u3044\u306e\u3060\u3051\u3069\u306d\u3002\u3055\u3063\u304d\u8a00\u3063\u305f\u901a\u308a\u3067\u3059\u3002<br \/>\u3082\u3063\u3068\u3082\u4eca\u56de\u306e\u4f8b\u3067\u306f\u30011\u6587\u3060\u3051\u3060\u304b\u3089\u3001<\/p>\n<pre>push(@data,{id=>$1,name=>$2}) if(m\/^([0-9]+)\\s+(.+)$\/);<\/pre>\n<p>\u3053\u306e\u65b9\u304c\u597d\u304d\u3060\u3051\u3069\u306d\u3002<br \/>\u3051\u3069\u3001\u3082\u3057\u3053\u306e\u5f8c\u306b\u3072\u305f\u3059\u3089\u51e6\u7406\u304c\u7d9a\u304f\u306a\u3089next\u3067\u98db\u3070\u3059\u306e\u306f\u5f97\u7b56\u3060\u304b\u3089\u3001or next\u306f\u4fbf\u5229\u304b\u3082\u3057\u308c\u306a\u3044\u3002<br \/>\u3057\u304b\u3057\u3001\u3053\u3046\u3044\u3046\u306e\u3082\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n<pre>while(1){<br \/>  my $line=<>;<br \/>  $line =~ m\/^\\s*$\/ and last;<br \/>}<\/pre>\n<p>\u7a7a\u767d\u6587\u5b57(\u6539\u884c\u542b\u3080)\u3060\u3051\u3092\u6253\u3061\u8fbc\u307e\u308c\u305f\u3068\u304d\u306flast\u3067\u629c\u3051\u51fa\u3059\u3068\u3002<br \/>\u975e\u5e38\u306b\u30a4\u30e1\u30fc\u30b8\u306e\u6cb8\u304d\u306b\u304f\u3044\u66f8\u304d\u65b9\u3060\u3002\u3057\u304b\u3082\u3053\u3093\u306a\u306e\u306f\u3001<\/p>\n<pre>last if($line =~ m\/^\\s*$\/);<\/pre>\n<p>\u3053\u306e\u65b9\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3088\u306d\u3002<br \/>if\u306f\u975e\u5e38\u306b\u8eab\u8fd1\u3067\u3059\u304b\u3089\u306d\u3002\u3060\u304b\u3089\u3064\u3044\u3064\u3044\u4f7f\u3044\u305f\u304f\u306a\u308b\u3002<br \/>\u3057\u304b\u3057\u6163\u308c\u308c\u3070\u3053\u308c\u3082\u3044\u3044\u3068\u601d\u3048\u308b\u3068\u304d\u304c\u6765\u308b\u306e\u3060\u308d\u3046\u304b\u3002<\/p>\n<hr \/>\n<p>Perl\u306e\u30e2\u30c3\u30c8\u30fc\u3068\u3044\u3048\u3070\u3044\u3044\u306e\u3060\u308d\u3046\u304b\u3001<br \/>\"There's More Than One Way To Do It\"<br \/>\u610f\u5473\u306f\u3001\u3084\u308a\u65b9\u306f\u3044\u304f\u3089\u3067\u3082\u3042\u308b\u3002<br \/>or next\u306b\u305b\u3088and last\u306b\u305b\u3088\u3001C\u306a\u3069\u3067\u306f\u307e\u305a\u4f7f\u3046\u3053\u3068\u306e\u306a\u3044\u3084\u308a\u65b9\u3060\u3051\u3069\u3001Perl\u3067\u306f\u666e\u901a\u306b\u4f7f\u3046\u3002<br \/>or die\u306f\u4fbf\u5229\u3060\u304b\u3089\u306d\u3002\u3046\u3093\u3002<br \/>\u6570\u3042\u307e\u305f\u306e\u7701\u7565\u8868\u8a18\u3082\u4fbf\u5229\u306a\u5834\u5408\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u5834\u5408\u304c\u3042\u308b\u3051\u3069\u3001\u305d\u306e\u8fba\u306f\u81ea\u5206\u3067\u8003\u3048\u308d\u3068\u3002<br \/>\u305d\u3046\u3044\u3046\u3053\u3068\u306a\u3093\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u3053\u3046\u3044\u3046\u98a8\u306bor,and\u3092\u4f7f\u3046\u306e\u306for die\u3060\u3051\u3068\u3044\u3046\u306e\u3082\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3088\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u65e5\u3061\u3087\u3063\u3068or die\u306e\u8a71\u3092\u53d6\u308a\u4e0a\u3052\u305f\u3051\u3069\u3001\u3042\u308c\u306f\u7d50\u69cb\u5909\u306a\u4ed5\u639b\u3051\u3089\u3057\u3044\u3002 open IF,&#8217;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1378","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1378"}],"version-history":[{"count":0,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1378\/revisions"}],"wp:attachment":[{"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}