{"id":1309,"date":"2008-06-08T22:27:00","date_gmt":"2008-06-08T13:27:00","guid":{"rendered":"https:\/\/hdmr.org\/d\/?e=25"},"modified":"2008-06-08T22:27:00","modified_gmt":"2008-06-08T13:27:00","slug":"blogn-25","status":"publish","type":"post","link":"http:\/\/hdmr.org\/d\/?e=25","title":{"rendered":"Perl\u3092\u4f7f\u3048\u3070\u4ed5\u4e8b\u3092\u3055\u307c\u308c\u308b"},"content":{"rendered":"<p>Perl\u306f\u4f55\u304b\u3068\u4fbf\u5229\u306a\u3082\u306e\u3060\u3002<br \/>\u3053\u3046\u3044\u3046\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d44\u3080\u3068\u3001\u975e\u5e38\u306b\u5384\u4ecb\u306a\u4ed5\u4e8b\u304c\u3059\u3050\u7d42\u308f\u308b\u3002<br \/>\u4f5c\u6210\u6642\u9593\u3084\u3089\u8003\u3048\u308b\u3068\u624b\u4f5c\u696d\u3067\u8abf\u3079\u305f\u65b9\u304c\u901f\u304f\u306a\u3044\u304b\u3068\u8a00\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u3051\u3069\u3001\u304b\u3063\u305f\u308b\u3044\u3002<\/p>\n<pre>open(LS1,\"ls \/cygdrive\/c\/dir1 |\");<br \/>open(LS2,\"ls \/cygdrive\/c\/dir2 |\");<br \/>@ls2=<ls2>;<br \/>while($v=<ls1>){<br \/>  ($v1,)=split(\/\\.\/,$v);<br \/>  $f=1;<br \/>  foreach(@ls2){<br \/>    ($v2,)=split(\/\\.\/,$_);<br \/>    if($v1 eq $v2){$f=0; break;}<br \/>  }<br \/>  if($f!=0){print \"$v\";}<br \/>}<\/pre>\n<p>\u3069\u3046\u3044\u3046\u3053\u3068\u304b\u3068\u3044\u3046\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u5909\u63db\u3092\u3057\u3066\u308b\u3093\u3060\u3051\u3069\u3001\u5909\u63db\u6f0f\u308c\u3092\u78ba\u304b\u3081\u308b\u305f\u3081\u306b\u4f5c\u6210\u3057\u305f\u3002<br \/>Cygwin\u4e0a\u3067\u52d5\u304b\u3059\u90fd\u5408ls\u3092\u4f7f\u3063\u3066\u308b\u304c\u3001ActivePerl\u306a\u3069\u3067Windows\u3067\u76f4\u63a5\u52d5\u4f5c\u3055\u305b\u308b\u4eba\u306fdir \/b\u3067\u3044\u3044\u304b\u3068\u3002<\/p>\n<hr \/>\n<p>\u6163\u308c\u3066\u308b\u4eba\u306a\u3089\u30b9\u30e0\u30fc\u30ba\u306b\u4f5c\u6210\u3067\u304d\u308b\u3093\u3060\u308d\u3046\u304c\u3001split\u306e\u5f15\u6570\u306e\u9806\u5e8f\u3092\u9593\u9055\u3048\u305f\u308a\u3067\u306a\u304b\u306a\u304b\u3002<br \/>\u3057\u304b\u3057\u3001\u3053\u3046\u3044\u3046\u4ed5\u4e8b\u3092\u3055\u305b\u308b\u306b\u306f\u3082\u3063\u3066\u3053\u3044\u306a\u306e\u306f\u4eca\u65e5\u78ba\u8a8d\u3067\u304d\u305f\u3068\u601d\u3046\u3002<br \/>\u3051\u3069\u3001\u914d\u5217\u3092\u5909\u6570\u306b\u5c55\u958b\u3057\u3066\u53d7\u3051\u53d6\u308b\u65b9\u6cd5\u3001\u306a\u304b\u306a\u304b\u30e6\u30cb\u30fc\u30af\u3067\u3059\u306d\u3002<\/p>\n<pre>($a,$b,$c)=split(\/\\,\/,\"\u5c71\u7530,\u7530\u4e2d,\u4e2d\u6751\");<\/pre>\n<p>(1,2,3)\u3068\u3044\u3046\u306e\u66f8\u304d\u65b9\u306f\u914d\u5217\u306e\u4f5c\u6210\u65b9\u6cd5\u305d\u306e\u3082\u306e\u3067\u3059\u304b\u3089\u306d\u3002<br \/>\u4f5c\u6210\u3082\u3001\u5c55\u958b\u3082\u540c\u3058\u65b9\u6cd5\u306a\u3068\u3053\u308d\u304c\u306d\u3002<br \/>PHP\u3082Perl\u304b\u3089\u304b\u306a\u308a\u5f71\u97ff\u3092\u53d7\u3051\u3066\u308b\u3088\u3046\u3067\u3001list\u95a2\u6570\u3068\u3044\u3046\u306e\u3067\u53d7\u3051\u53d6\u308c\u308b\u3051\u3069\u3001\u3053\u308c\u3082\u30e6\u30cb\u30fc\u30af\u3002<br \/>\u305d\u308c\u3092\u4f7f\u3063\u3066\u4e0a\u3067\u306f\u3001\u62e1\u5f35\u5b50\u3092\u9664\u3044\u305f\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\u3057\u3066\u308b\u308f\u3051\u3060\u3002<br \/>\u3044\u3084\u3001\u304b\u306a\u308a\u7c21\u6613\u306a\u65b9\u6cd5\u3060\u3051\u3069\u306d\u3002\u307e\u3041\u3053\u308c\u3067\u3082OK\u3067\u3059\u3002<br \/>\u3042\u3068\u3001\u9023\u60f3\u914d\u5217\u306e\u30eb\u30fc\u30d7\u306e\u53d6\u308a\u6271\u3044\u3082\u30e6\u30cb\u30fc\u30af\u3060\u3068\u601d\u3063\u305f\u3002<\/p>\n<pre>while( ($k,$v) = each(%foo) ){print \"$k : $v\\n\"; }<\/pre>\n<p>1\u30641\u3064each\u3067\u53d6\u308a\u51fa\u3059\u3068\u3001\u30ad\u30fc\u3068\u5024\u306e\u914d\u5217\u3067\u53d7\u3051\u53d6\u308c\u308b\u3068\u3002<br \/>\u305d\u308c\u3092\u3053\u3046\u3084\u3063\u3066\u3084\u308b\u3068\u3002\u7121\u7406\u306b\u306a\u3063\u305f\u3089false\u306b\u76f8\u5f53\u3059\u308b\u5024\u3092\u9001\u308b\u3068\u3002<br \/>\u5b9f\u306f\u3001\u9023\u60f3\u914d\u5217\u306fforeach\u56de\u3057\u3066\u3082\u3046\u307e\u304f\u56de\u3089\u3093\u306e\u3088\u306d\u3002<br \/>\u3067\u8abf\u3079\u308b\u3068\u3053\u3046\u3059\u308b\u3068\u3044\u3044\u3068\u3002\u306a\u308b\u307b\u3069\u3002<br \/>\u914d\u5217\u3092\u5909\u6570\u306b\u5c55\u958b\u3067\u304d\u308b\u304b\u3089\u3053\u305d\u4f7f\u3048\u308b\u6280\u3060\u306a\u3002\u307e\u3041\u305d\u3046\u3058\u3083\u306a\u304f\u3066\u3082\u4f7f\u3048\u306a\u3044\u3053\u3068\u306f\u306a\u3044\u3051\u3069\u3002<\/p>\n<hr \/>\n<p>\u305d\u3093\u306aPerl\u3067\u56f0\u3063\u305f\u3053\u3068\u306f\u3001\u8907\u6570\u884c\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u304c\u3067\u304d\u306a\u3044\u3053\u3068\u3002<br \/>\u3057\u304b\u3057\u3001\u3069\u3046\u3082\u3053\u3093\u306a\u65b9\u6cd5\u304c\u3042\u308b\u3089\u3057\u3044\u3002<\/p>\n<pre>=pod <br \/>foreach (@ls2){ <br \/>  print ;<br \/>}<br \/>=cut<\/pre>\n<p>\u306a\u305c\u3053\u308c\u3067\u3044\u3044\u306e\u304b\u306f\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u3002\u3051\u3069\u3067\u304d\u306a\u3044\u3053\u3068\u306f\u306a\u3044\u3089\u3057\u3044\u3002<br \/>\u3061\u306a\u307f\u306bPerl\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u306f\u666e\u901a#\u3092\u4f7f\u3046\u3002\u305d\u3046\u306a\u3093\u3060\u3088\u306d\u3002<br \/>\u3068\u3001\u3044\u308d\u3044\u308d\u3084\u3063\u3066\u307e\u3057\u305f\u304c\u3001Perl\u306f\u975e\u5e38\u306b\u624b\u9593\u304c\u7701\u3051\u3066\u3044\u3044\u3002<br \/>\u30c6\u30b9\u30c8\u52c9\u5f37\u3067\u3001\u7e70\u308a\u8fd4\u3057\u8a08\u7b97\u3070\u3063\u304b\u308a\u3067\u3081\u3093\u3069\u304f\u3055\u304b\u3063\u305f\u304b\u3089\u3001\u6b63\u3057\u3044\u304b\u78ba\u304b\u3081\u308b\u305f\u3081\u306bPerl\u3092\u4f7f\u3063\u305f\u3068\u3044\u3046\u306e\u304c\u4eca\u65e5\u3042\u3063\u3066\u306d\u3002<br \/>\u305d\u308c\u3067\u3061\u3087\u3063\u3068\u53d6\u308a\u4e0a\u3052\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Perl\u306f\u4f55\u304b\u3068\u4fbf\u5229\u306a\u3082\u306e\u3060\u3002\u3053\u3046\u3044\u3046\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d44\u3080\u3068\u3001\u975e\u5e38\u306b\u5384\u4ecb\u306a\u4ed5\u4e8b\u304c\u3059\u3050\u7d42\u308f\u308b\u3002\u4f5c\u6210\u6642\u9593\u3084\u3089\u8003\u3048\u308b\u3068\u624b\u4f5c\u696d\u3067\u8abf\u3079\u305f\u65b9\u304c\u901f\u304f\u306a\u3044\u304b\u3068\u8a00\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u3051\u3069\u3001\u304b\u3063\u305f\u308b\u3044\u3002 open(LS1,&#8221;ls \/cygdrive\/ [&hellip;]<\/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-1309","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1309"}],"version-history":[{"count":0,"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=\/wp\/v2\/posts\/1309\/revisions"}],"wp:attachment":[{"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1309"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hdmr.org\/d\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}