開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの機能制限無料版、light版)
- Script言語:Perl
『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2) の14章(文字列処理とソート)、14.5(練習問題)1を解いてみる。
その他参考書籍
1.
コード(TextWrangler)
sample.pl
#!/usr/bin/env perl use strict; use warnings; use utf8; use 5.012; binmode STDOUT, ':utf8'; binmode STDIN, ':utf8'; use File::Basename; use File::Spec::Functions; my @numbers = (); while(<>){ push @numbers, split; } for(sort{$a <=> $b} @numbers){ printf "%10g\n", $_; }
入出力結果(Terminal)
$ ./sample.pl numbers -40 -10 0 0 1 1.5 1.5 2 2.71828 3.14159 4 4 9 17 42 98.6 666 1000 2001 2001 90210 $ cat numbers 17 1000 04 1.50 3.14159 -10 1.5 4 2001 90210 666 9 0 2 1 0 2001 42 -40 98.6 2.71828 $
0 コメント:
コメントを投稿