開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの機能制限無料版、light版)
- Script言語:Perl
『続・初めてのPerl 改訂版』(Randal L. Schwartz, brian d foy, Tom Phoenix 著、伊藤 直也、田中 慎司、吉川 英興 監訳、株式会社ロングテール/長尾 高弘 訳、オライリー・ジャパン、2006年、ISBN4-87311-305-9) の9章(リファレンスを使った実践的なテクニック), 9.9(練習問題)3を解いてみる。
その他参考書籍
3.
コード(TextWrangler)
sample.pl
#!/usr/bin/env perl use strict; use warnings; use utf8; use 5.016; my @strings = qw(Professor skipper professor Skipper); my @dictionary_sorted = map $_->[0], sort { $a->[1] cmp $b->[1]} map { my $string = $_; $string =~ tr/A-Z/a-z/; $string =~ tr/a-z//cd; [$_, $string]} @strings; for ((\@strings, \@dictionary_sorted)){ print map{"$_\n"} @$_; print "\n"; }
入出力結果(Terminal)
$ ./sample.pl Professor skipper professor Skipper Professor professor skipper Skipper $
0 コメント:
コメントを投稿