開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs(Text Editor)
- プログラミング言語: Perl
『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2)の10章(さまざまな制御構造)の10.11(練習問題)3を解いてみる。
その他参考書籍
3.
コード(BBEdit)
sample.pl
#!/usr/bin/env perl use strict; use warnings; use 5.016; use utf8; binmode STDOUT, ':utf8'; binmode STDIN, ':utf8'; $ENV{UNDEFINED} = undef; $ENV{EMPTY} = ""; $ENV{ZERO} = 0; my $cols = 0; for (keys %ENV) { my $length = length $_; $cols = $length if $length > $cols; } for (sort keys %ENV) { printf "%-${cols}s: %s\n", $_, $ENV{$_} // "undefined"; }
入出力結果(Terminal)
$ ./sample.pl Apple_PubSub_Socket_Render: /tmp/launch-ne6Lje/Render Apple_Ubiquity_Message : /tmp/launch-2V0kjb/Apple_Ubiquity_Message COMMAND_MODE : unix2003 DISPLAY : /tmp/launch-WMmpD4/org.x:0 EMPTY : HOME : /Users/kamimura LANG : ja_JP.UTF-8 LOGNAME : kamimura OLDPWD : /Users/kamimura/documents/c PATH : /Users/kamimura/pear/bin/:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin/:/Library/Frameworks/Python.framework/Versions/3.2/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/MacGPG2/bin PWD : /Users/kamimura/documents/perl SECURITYSESSIONID : 186a6 SHELL : /bin/bash SHLVL : 1 SSH_AUTH_SOCK : /tmp/launch-ZP9cVK/Listeners TERM : xterm-256color TERM_PROGRAM : Apple_Terminal TERM_PROGRAM_VERSION : 303.2 TERM_SESSION_ID : C8451C9A-0DBD-47B1-9BBD-B4D3D4E331F6 TMPDIR : /var/folders/1v/dvc2tljs2_z3zqn56g_29rl00000gn/T/ UNDEFINED : undefined USER : kamimura ZERO : 0 _ : ./sample.pl __CF_USER_TEXT_ENCODING : 0x1F5:0:0 $
0 コメント:
コメントを投稿