2012年5月29日火曜日

開発環境

初めてのPerl 第7版 (Randal L. Schwartz (著)、 brian d foy (著)、Tom Phoenix (著)、 近藤 嘉雪 (翻訳)、嶋田 健志 (翻訳)、オライリージャパン) の7章(正規表現の世界), 7.4(練習問題)3を解いてみる。

3.

やり方の1つ。(「やり方は何通りもある」(TIMTOWTDI(There Is More Than One Way To Do It.)))

コード(TextWrangler)

#!/usr/bin/env perl
use strict;
use warnings;

while(<>){
  chomp;
  print "$_\n" if /\./;
}

入出力結果(Terminal)

$ perl sample.pl tmp
Mr. Slate
$ cat tmp
fred flintstone
frederick
Alfred
abcde
perl
python
ruby
php
javascript
kamimura
Fred
frederick
Alfred
Mr. Slate
C#
$

0 コメント:

コメントを投稿