開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの機能制限無料版、light版)
- Script言語:Perl
『初めてのPerl 第5版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-427-9) の16章(プロセス管理), 16.8(練習問題)1を解いてみる。
1.
やり方の1つ。(「やり方は何通りもある」(TIMTOWTDI(There Is More Than One Way To Do It.)))
コード(TextWrangler)
#!/usr/bin/env perl use strict; use warnings; my $dir = "/"; chdir $dir or die "can't chdir $dir: $!"; system "ls","-l";
入出力結果(Terminal)
$ perl sample.pl total 30453 drwxrwxr-x+ 66 root admin 2244 4 9 12:54 Applications drwxrwxr-x 15 root admin 510 11 19 00:21 Developer drwxrwxr-x@ 19 root admin 646 8 6 2011 Developer-3.2.6 drwxr-xr-x+ 66 root wheel 2244 3 13 19:04 Library drwxr-xr-x@ 2 root wheel 68 8 17 2011 Network drwxr-xr-x+ 4 root wheel 136 2 2 18:03 System drwxr-xr-x 5 root admin 170 10 16 11:43 Users drwxrwxrwt@ 5 root admin 170 4 11 12:56 Volumes drwxr-xr-x@ 39 root wheel 1326 2 2 17:52 bin drwxrwxr-t@ 2 root admin 68 8 17 2011 cores dr-xr-xr-x 3 root wheel 4221 4 9 12:42 dev lrwxr-xr-x@ 1 root wheel 11 10 16 11:32 etc -> private/etc dr-xr-xr-x 2 root wheel 1 4 10 14:36 home -rw-r--r--@ 1 root wheel 15566052 1 13 11:49 mach_kernel dr-xr-xr-x 2 root wheel 1 4 10 14:36 net drwxr-xr-x 3 root admin 102 9 5 2011 opt drwxr-xr-x@ 6 root wheel 204 10 16 11:43 private drwxr-xr-x@ 62 root wheel 2108 2 2 17:53 sbin lrwxr-xr-x@ 1 root wheel 11 10 16 11:35 tmp -> private/tmp drwxr-xr-x@ 14 root wheel 476 10 20 17:46 usr lrwxr-xr-x@ 1 root wheel 11 10 16 11:35 var -> private/var lrwxr-xr-x 1 root admin 60 3 23 2010 ユーザーズガイドと情報 -> /Library/Documentation/User Guides and Information.localized $
0 コメント:
コメントを投稿