{"id":34,"date":"2018-01-14T11:49:48","date_gmt":"2018-01-14T02:49:48","guid":{"rendered":"https:\/\/pocolog.bass-world.net\/tech\/?p=34"},"modified":"2018-01-14T11:49:48","modified_gmt":"2018-01-14T02:49:48","slug":"perl-recursive-copy","status":"publish","type":"post","link":"https:\/\/pocolog.bass-world.net\/tech\/2018\/perl-recursive-copy\/","title":{"rendered":"[Perl] \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u518d\u5e30\u7684\u306b\u305f\u3069\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3059\u308b"},"content":{"rendered":"<blockquote>\n<pre><code>#!\/usr\/bin\/perl\nuse strict;\nuse File::Copy;\n\nmy $srcFile = $ARGV[0]; # \u30b3\u30d4\u30fc\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\nprint \"src file : $srcFile\\n\";\n\n# \u518d\u5e30\u30b3\u30d4\u30fc\u95a2\u6570\nsub recurseCopy{\n\tmy($src, $dir) = @_;\n\tmy @files = ();\n\t\n\tprint \"entering $dir\\n\";\n\t\n\t# \u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\n\topendir(DIR, $dir) or die(\"Can not open directory : $dir\\n\");\n\t@files = readdir(DIR);\n\tclosedir(DIR);\n\t\n\tforeach my $file(sort @files){\n\t\tnext if($file =~ \/^\\.{1,2}$\/);\n\t\tif(-d \"$dir\/$file\"){\n\t\t\t# \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u3001\u518d\u5e30\u30b3\u30d4\u30fc\u547c\u3073\u51fa\u3057\n\t\t\trecurseCopy($srcFile, \"$dir\/$file\");\n\t\t}\n\t}\n\tprint \"copying $src to $dir\\n\";\n\t# \u81ea\u5206\u81ea\u8eab\u306b\u306f\u30b3\u30d4\u30fc\u3057\u306a\u3044\n\tif($dir ne \"\\.\"){\n\t\tcopy($srcFile, $dir);\n\t}\n}\nprint \"start\\n\";\nmy $b = recurseCopy($srcFile, \".\");\nprint \"end\\n\";<\/code><\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>#!\/usr\/bin\/perl use strict; use File::Copy; my $srcFile = $ARGV[0]; # \u30b3\u30d4\u30fc\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97 print &#8220;src file : $srcFile &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/pocolog.bass-world.net\/tech\/2018\/perl-recursive-copy\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;[Perl] \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u518d\u5e30\u7684\u306b\u305f\u3069\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,11],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-linux","category-perl"],"_links":{"self":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":0,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts\/34\/revisions"}],"wp:attachment":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/media?parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/categories?post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/tags?post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}