2012年10月9日火曜日

開発環境

『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2) の16章(プロセス管理)、16.9(練習問題)2を解いてみる。

その他参考書籍

2.

コード(TextWrangler)

sample.pl

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.012;
binmode STDOUT, ':utf8';
binmode STDIN, ':utf8';

open STDOUT, ">", "ls.out" or die "can't write to ls.out: $!";
open STDERR, ">", "ls.err" or die "can't write to ls.err: $!";
chdir "/" or die "can't chdir to /: $!";
exec 'ls', '-l' or die "can't exec ls: $!";

入出力結果(Terminal)

$ ./sample.pl
$ cat ls.out
total 30461
drwxrwxr-x+ 62 root  admin      2108 10  8 23:23 Applications
drwxrwxr-x@ 19 root  admin       646  8  6  2011 Developer-3.2.6
drwxr-xr-x+ 68 root  wheel      2312  4 23 23:20 Library
drwxr-xr-x@  2 root  wheel        68  8 17  2011 Network
drwxr-xr-x+  4 root  wheel       136  9 20 08:39 System
drwxr-xr-x   5 root  admin       170 10 16  2011 Users
drwxrwxrwt@  6 root  admin       204 10  9 13:38 Volumes
drwxr-xr-x@ 39 root  wheel      1326  9 20 08:31 bin
drwxrwxr-t@  2 root  admin        68  8 17  2011 cores
dr-xr-xr-x   3 root  wheel      4507 10  5 14:36 dev
lrwxr-xr-x@  1 root  wheel        11 10 16  2011 etc -> private/etc
dr-xr-xr-x   2 root  wheel         1 10  9 09:09 home
drwxrwxrwt   3 root  wheel       102  7  1 22:10 lost+found
-rw-r--r--@  1 root  wheel  15572704  8 24 08:27 mach_kernel
dr-xr-xr-x   2 root  wheel         1 10  9 09:09 net
drwxr-xr-x   3 root  admin       102  9  5  2011 opt
drwxr-xr-x@  6 root  wheel       204 10 16  2011 private
drwxr-xr-x@ 62 root  wheel      2108  9 20 08:31 sbin
lrwxr-xr-x@  1 root  wheel        11 10 16  2011 tmp -> private/tmp
drwxr-xr-x@ 15 root  wheel       510  5 10 10:20 usr
lrwxr-xr-x@  1 root  wheel        11 10 16  2011 var -> private/var
lrwxr-xr-x   1 root  admin        60  3 23  2010 ユーザーズガイドと情報 -> /Library/Documentation/User Guides and Information.localized
$ cat ls.err
$

0 コメント:

コメントを投稿